FilamentF
Filament7mo ago
Xavi

How to pass parameter to list page

I want to pass channel paramter and get on list.. i add here

public static function getPages(): array
    {
        return [
            'index' => Pages\ListMessageImap::route('/{channel}'),
            'create' => Pages\CreateMessageImap::route('/create'),
            'edit' => Pages\EditMessageImap::route('/{record}/edit'),
        ];
    }

and pass like this

NavigationItem::make($channel->name)
                        ->group('Channels')
                        ->url(fn(): string => route('filament.user.resources.message-imaps.index', [
                                'tenant' => Filament::getTenant(),
                                'channel' => $channel->id]
                        ))
                        ->icon('heroicon-o-envelope-open');


and on list, i add this

class ListMessageImap extends ListRecords
{
    protected static string $resource = MessageImapResource::class;

    #[Url]
    public string $channel;

    protected function getHeaderActions(): array
    {
        return [
            Actions\CreateAction::make(),
        ];
    }

    protected function getTableQuery(): ?Builder
    {
        return Message::query()
            ->where('channel_id', $this->channel);
    }
} 


but it doesnt works. Any ideas?

Thanks!
Was this page helpful?