104 lines
3.1 KiB
PHP
104 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Courses\RelationManagers;
|
|
|
|
use Filament\Actions\AttachAction;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\DetachAction;
|
|
use Filament\Actions\DetachBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Actions\ViewAction;
|
|
use Filament\Forms\Components\DatePicker;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Infolists\Components\TextEntry;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class KidsRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'kids';
|
|
|
|
public function isReadOnly(): bool
|
|
{
|
|
return false;
|
|
}
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('name')
|
|
->required(),
|
|
TextInput::make('email')
|
|
->label('Email address')
|
|
->email(),
|
|
]);
|
|
}
|
|
|
|
public function infolist(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextEntry::make('created_at')
|
|
->dateTime()
|
|
->placeholder('-'),
|
|
TextEntry::make('updated_at')
|
|
->dateTime()
|
|
->placeholder('-'),
|
|
TextEntry::make('name'),
|
|
TextEntry::make('email')
|
|
->label('Email address')
|
|
->placeholder('-'),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('name')
|
|
->columns([
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
TextColumn::make('updated_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
TextColumn::make('name')
|
|
->searchable(),
|
|
TextColumn::make('email')
|
|
->label('Email address')
|
|
->searchable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->headerActions([
|
|
CreateAction::make(),
|
|
AttachAction::make()
|
|
->form(fn (AttachAction $action): array => [
|
|
$action->getRecordSelect(),
|
|
DatePicker::make('date')->required(),
|
|
])->preloadRecordSelect()
|
|
])
|
|
->recordActions([
|
|
ViewAction::make(),
|
|
EditAction::make(),
|
|
DetachAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DetachBulkAction::make(),
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|