Resources
Relation managers
A table of a relationship under a record's pages, with create, edit and delete in modals.
php artisan make:xelqun-relation-manager Customer orders
use Xelqun\Forms\Components\TextInput;
use Xelqun\Panels\Resources\RelationManager;
use Xelqun\Tables\Columns\TextColumn;
class OrdersRelationManager extends RelationManager
{
protected static string $relationship = 'orders';
public static function form(): array
{
return [TextInput::make('number')->required()];
}
public static function columns(): array
{
return [TextColumn::make('number')->searchable()];
}
}
Return it from getRelations() on the resource.
public static function getRelations(): array
{
return [OrdersRelationManager::class];
}
With two or more, the tables sit on tabs under the record. Set $relatedResource to reuse a resource's form, columns and filters.
It works for has-many, morph-many and many-to-many, where a new record is attached to the parent.


Access
Access goes through the related model's policy and the parent's view. Changing anything also takes the parent's update, and the view page is read-only.
Linking existing records
See attach and associate. See it in the demo, below the order's form.