FilamentF
Filament11mo ago
foggy

Newb question: populating table based on query

Hi all - kinda new to Filament, been hacking around with Lara/Livewire for a while, now starting to migrate my app over to Filament bit by bit learning as I go. I'm calling Filament parts as Livewire components.

My app is multi-tenanted. Objects in various databases belong to 'organisations' or other groupings. In Lara/Livewire, I'd pass the collection into the Livewire component based off a query $users=User::where('organisation',Session::get('currentOrg'))->get();

The Filament code I'm working off looks like this:

return $table ->query(User::query()) ->columns([ TextColumn::make('name') ->searchable(isIndividual: true, isGlobal: false) ->sortable() ->label('Full Name'), TextColumn::make('email') ->label('Email Address') ->searchable(isIndividual: true, isGlobal: false) ->sortable(),

Clearly, it's returning a table with all the users in the database. How do I filter that to just those records where the organisation field = whatever?

Everything I google for this seems to give me quite complex answers, but my spidey sense tells me there's a simpler way.. TIA..
Was this page helpful?