How resources work
When your Laravel app boots, Exo scans theapp/Exo/Resources directory and registers every resource class it finds. For each resource, Exo:
- Creates API endpoints under
/exo-api/resources/{name}for listing, creating, updating, and deleting records - Attaches model observers that fire webhook events on create, update, and delete
- Makes the resource available for webhook subscriptions
Required methods
Every resource must extendExowizz\Exo\Resource and implement four methods:
| Method | What it does |
|---|---|
name() | A unique identifier used in API URLs, e.g. /exo-api/resources/contact |
model() | The fully-qualified Eloquent model class to expose |
triggers() | Which events fire webhooks: on_create, on_update, on_delete |
transform() | Converts a model instance into the array returned by the API |
Optional methods
Beyond the four required methods, resources have many optional methods you can override:| Method | Purpose | Default |
|---|---|---|
ownerColumn() | Scope records to a user | null (admin-only) |
ownerIsRelationship() | Whether the owner column is a relationship | false |
searchableColumns() | Columns searchable via ?search= | [] (disabled) |
applySearch() | Custom search query logic | OR LIKE on searchableColumns |
baseQuery() | Starting query (add scopes, eager loads) | Model::query() |
createRules() | Validation rules for creating records | [] |
updateRules() | Validation rules for updating records | [] |
performCreate() | Custom create logic | Model::create() |
performUpdate() | Custom update logic | $model->update() |
supportsCreate() | Whether creation is allowed | true |
supportsUpdate() | Whether updates are allowed | true |
supportsDelete() | Whether deletion is allowed | true |
webhookQueue() | Queue name for this resource’s webhooks | config('exo.queue') |
isAdmin() | Whether the current user is an admin | Uses config('exo.is_admin') |
Creating resources
The fastest way to create a resource is with the Artisan command:app/Exo/Resources/ContactResource.php with all methods stubbed out.
You can also run the command without arguments for an interactive experience:
Exo auto-discovers resources in the
app/Exo/Resources directory. You can change this location in the configuration.Resource discovery
Exo looks for resource classes in the path defined byconfig('exo.resources_path') (default: app/Exo/Resources). Any PHP class in that directory that extends Exowizz\Exo\Resource is automatically registered when your app boots.
The namespace for discovery is set by config('exo.resources_namespace') (default: App\Exo\Resources). If you move your resources to a different directory, update both config values to match.