authorize('create'); $this->hidden(fn (BaseRelationManager $livewire) => !($livewire->getRelationship() instanceof BelongsToMany)); $this->recordSelect(function (BaseRelationManager $livewire) { /** @var string */ $model = $livewire->getTable()->getModel(); $title = $livewire->getTable()->getRecordTitle(new $model); return Select::make('recordId') ->label($title) ->useScout($model); }); $this->form(function (Form $form, AttachAction $action) { return $form ->schema([ $action->getRecordSelect(), TextInput::make(AnimeResource::ATTRIBUTE_AS) ->label(__('filament.fields.anime.resources.as.name')) ->helperText(__('filament.fields.anime.resources.as.help')) ->visibleOn([ AnimeResourceRelationManager::class, ArtistResourceRelationManager::class, SongResourceRelationManager::class, StudioResourceRelationManager::class, ResourceRelationManager::class, ]), TextInput::make(ArtistSong::ATTRIBUTE_AS) ->label(__('filament.fields.artist.songs.as.name')) ->helperText(__('filament.fields.artist.songs.as.help')) ->visibleOn([ ArtistSongRelationManager::class, SongArtistRelationManager::class, ]), ]); }); $this->after(fn ($livewire, $record) => $this->pivotActionLog('Attach', $livewire, $record)); } }