Files
ntspi-app/app/Filament/Resources/DepartmentResource/RelationManagers/TeachersRelationManager.php
T
2024-09-19 16:06:49 +05:00

62 lines
1.8 KiB
PHP

<?php
namespace App\Filament\Resources\DepartmentResource\RelationManagers;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Actions\AttachAction;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class TeachersRelationManager extends RelationManager
{
protected static string $relationship = 'teachers';
protected static ?string $inverseRelationship = 'departments_teach';
protected static ?string $title = 'Преподаватели кафедры';
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
->required()
->maxLength(255),
]);
}
public function table(Table $table): Table
{
return $table
->recordTitleAttribute('name')
->columns([
Tables\Columns\TextColumn::make('name'),
])
->filters([
//
])
->headerActions([
AttachAction::make()
->form(fn (AttachAction $action): array => [
$action->getRecordSelect(),
Forms\Components\TextInput::make('teaching_position')->label('Преподавательская должность')->required(),
])
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
]),
]);
}
}