Поля сводной таблицы в Filament
Давайте зададим поля сводной таблицы. При прикреплении навыка к работнику можно сохранить не только связь, но и роль в pivot. Проверим на /admin/posts/1/edit.
У AttachAction в менеджере
tags зададим схему
с полем роли. Значение уйдёт
в сводную таблицу вместе
с парой записей.
Откроем TagsRelationManager.php:
<?php
namespace App\Filament\Resources\Posts\RelationManagers;
use Filament\Actions\AttachAction;
use Filament\Forms\Components\TextInput;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class TagsRelationManager extends RelationManager
{
protected static string $relationship = 'tags';
public function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('name'),
])
->headerActions([
AttachAction::make()
->schema([
TextInput::make('role'),
]),
]);
}
}
?>
При прикреплении навыка к работнику спросите роль.