<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
guava / filament-modal-relation-managers example snippets
use Guava\FilamentModalRelationManagers\Concerns\CanBeEmbeddedInModals;
class LessonsRelationManager extends RelationManager
{
use CanBeEmbeddedInModals;
// ...
}
use Guava\FilamentModalRelationManagers\Actions\Table\RelationManagerAction;
// for example in a resource table
class CourseResource extends Resource {
// ...
public static function table(Table $table): Table
{
return $table
->actions([
RelationManagerAction::make('lesson-relation-manager')
->label('View lessons')
->relationManager(LessonRelationManager::make()),
])
// ...
;
}
// ...
}
use Guava\FilamentModalRelationManagers\Actions\Infolist\RelationManagerAction;
// for example in a resource infolist
class CourseResource extends Resource {
// ...
public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->schema([
TextEntry::make('title')
->suffixAction(RelationManagerAction::make()
->label('View lessons')
->relationManager(LessonRelationManager::make()))
])
// ...
;
}
// ...
}
use Guava\FilamentModalRelationManagers\Actions\Action\RelationManagerAction;
// for example in edit page
class EditCourse extends EditRecord {
// ...
protected function getHeaderActions(): array
{
return [
RelationManagerAction::make()
->label('View lessons')
->record($this->getRecord())
->relationManager(LessonRelationManager::make())
];
}
// ...
}