Pages · Laravilt
Nested Resources
Scope a child resource under a parent resource with hierarchical URLs.
A nested resource is a full resource (list, create, edit, view) scoped to one parent record, for example /admin/customers/{customer}/tags.
Creating a Nested Resource
bash
| Argument / option | Description |
|---|---|
name | Nested resource name (e.g. Tag) |
--parent= | Parent resource name (e.g. Customer) |
--model= | Model class (defaults to the name) |
--panel=Admin | Panel name |
--simple | Single ManageRecords page |
--force | Overwrite existing files |
The parent resource must already exist at app/Laravilt/{Panel}/Resources/{Parent}/{Parent}Resource.php. The command also adds the new class to the parent's getNestedResources().
Nested Resource
php
Parent Resource
php
Nested resources are registered through their parent. Don't add them to the panel yourself.
URL Structure
text
Accessing the Parent Record
php
Queries are scoped to the parent automatically through modifyQueryForParent().
Properties
| Property | Type | Description |
|---|---|---|
$parentResource | ?string | Parent resource class |
$parentRelationship | string | Relationship from child to parent |
$childRelationship | ?string | Relationship from parent to children (optional) |
$showInParentNavigation | bool | Show a link in the parent's sub-navigation (default true) |