When to use me
- Setting up a new model that needs Livewire components
- Changing index behaviour (columns, buttons, search, sorting)
- Configuring form fields and actions
- Before scaffolding any Livewire components that rely on resource config
Base Configuration
- Always use the full Eloquent model class for the
model key
routePrefix is only required for full-page components and may be omitted otherwise
- Only add buttons, search, or sorting when explicitly required
- If columns are explicitly defined, use them exactly as provided
- If no columns are defined, make sensible assumptions based on the model
- Only define options that are needed; do not invent configuration
- Remove example comments when creating for production use
'resource' => [
'model' => \App\Models\Model::class,
'routePrefix' => 'resource', // or 'admin.resource' for admin routes
'index' => [
'title' => '', // Page title for the index view
'columns' => [], // Column names shown in the index table
'buttons' => [], // Action buttons (create, edit, delete)
'searchableFields' => [], // Fields included in search
'sortColumn' => '', // Default sort column
'filterableFields' => [], // Fields included in filters
],
'form' => [
'title' => '', // Page title for the form view
'fields' => [], // Field names to include in the form
'buttons' => [], // Defines action buttons for the form view (save, cancel, etc.)
],
],
Button Types
Buttons define available actions on index and form pages. The suffix determines behavior:
No suffix (e.g., create, edit) - Opens a full page route
- Indicates full page component with route navigation
- Requires route if not included
-modal suffix (e.g., create-modal, edit-modal) - Opens a modal dialog
- Indicates modal form component typically rendered on the same page
- Uses events to trigger actions (do not just create an event)
Index Page Buttons
- use namespace when required.
| Button |
Button Code |
create |
<x-gt-resource-action action="create" :$routePrefix /> |
create-modal |
<x-gt-resource-action action="create" :$routePrefix dispatchTo="admin.courses.module-form-modal" text="Add Module" /> |
edit |
<x-gt-resource-action action="edit" :$routePrefix :id="$item->id" /> |
edit-modal |
<x-gt-resource-action action="edit" :id="$item->id" dispatchTo="admin::module.form-modal" /> |
show |
<x-gt-resource-action action="show" :$routePrefix :slug="$item->slug" target="_blank" /> |
delete |
<x-gt-resource-action action="delete" :id="$item->id" /> |
1---2name: livewire-resource-config3description: Define resource configuration in config/resources.php for Livewire components. Controls index and form behaviour including columns, buttons, search, sorting, and basic routing. Use this before generating or modifying Livewire components.4---56## When to use me78- Setting up a new model that needs Livewire components9- Changing index behaviour (columns, buttons, search, sorting)10- Configuring form fields and actions11- Before scaffolding any Livewire components that rely on resource config1213## Base Configuration1415- Always use the full Eloquent model class for the `model` key16- `routePrefix` is only required for full-page components and may be omitted otherwise17- Only add buttons, search, or sorting when explicitly required18- If columns are explicitly defined, use them exactly as provided19- If no columns are defined, make sensible assumptions based on the model20- Only define options that are needed; do not invent configuration21- Remove example comments when creating for production use2223```php +code24'resource' => [25 'model' => \App\Models\Model::class,26 'routePrefix' => 'resource', // or 'admin.resource' for admin routes27 28 'index' => [29 'title' => '', // Page title for the index view30 'columns' => [], // Column names shown in the index table31 'buttons' => [], // Action buttons (create, edit, delete)32 'searchableFields' => [], // Fields included in search33 'sortColumn' => '', // Default sort column34 'filterableFields' => [], // Fields included in filters35 ],36 37 'form' => [38 'title' => '', // Page title for the form view39 'fields' => [], // Field names to include in the form40 'buttons' => [], // Defines action buttons for the form view (save, cancel, etc.)41 ],42],43```4445<!-- 46AI DO NOT DO ANYTHING FROM HERE DOWN THIS IS WORK IN PROGRESS 47AI DO NOT DO ANYTHING FROM HERE DOWN THIS IS WORK IN PROGRESS 48AI DO NOT DO ANYTHING FROM HERE DOWN THIS IS WORK IN PROGRESS 49AI DO NOT DO ANYTHING FROM HERE DOWN THIS IS WORK IN PROGRESS 50AI DO NOT DO ANYTHING FROM HERE DOWN THIS IS WORK IN PROGRESS 51-->5253## Button Types5455Buttons define available actions on index and form pages. The suffix determines behavior:5657**No suffix** (e.g., `create`, `edit`) - Opens a full page route5859- Indicates full page component with route navigation60- Requires route if not included6162**`-modal` suffix** (e.g., `create-modal`, `edit-modal`) - Opens a modal dialog6364- Indicates modal form component typically rendered on the same page65- Uses events to trigger actions (do not just create an event)6667### Index Page Buttons6869- use namespace when required.7071| Button | Button Code |72| :------------- | :---------------------------------------------------------------------------------------------------------------------- |73| `create` | `<x-gt-resource-action action="create" :$routePrefix />` |74| `create-modal` | `<x-gt-resource-action action="create" :$routePrefix dispatchTo="admin.courses.module-form-modal" text="Add Module" />` |75| `edit` | `<x-gt-resource-action action="edit" :$routePrefix :id="$item->id" />` |76| `edit-modal` | `<x-gt-resource-action action="edit" :id="$item->id" dispatchTo="admin::module.form-modal" />` |77| `show` | `<x-gt-resource-action action="show" :$routePrefix :slug="$item->slug" target="_blank" />` |78| `delete` | `<x-gt-resource-action action="delete" :id="$item->id" />` |