F
Filament12mo ago
Askancy

Filter in the table but with different model

On a page referencing a table in the "Giochi" model, I would need to insert a filter but referencing the "InfoGiochi" table, which would be a pivot table. The "Giochi" table contains the name of the game, while "InfoGiochi" contains other data such as the date. I would need to get the contents where the "data" column is empty. I have tried unsuccessfully with:
Filter::make('Senza Data')
->query(fn () => InfoGiochi::query()->where('data', null)),
Filter::make('Senza Data')
->query(fn () => InfoGiochi::query()->where('data', null)),
But I don't understand how to connect to a model other than Games...
Solution:
Solved with: ```php Filter::make('Senza Data') ->query(function ($query) {...
Jump to solution
1 Reply
Solution
Askancy
Askancy12mo ago
Solved with:
Filter::make('Senza Data')
->query(function ($query) {
$query->whereHas('data_game', function ($query) {
Filter::make('Senza Data')
->query(function ($query) {
$query->whereHas('data_game', function ($query) {
public function data_game(): hasMany
{
return $this>hasMany(InfoGiochi::class, '**', 'id');
}
public function data_game(): hasMany
{
return $this>hasMany(InfoGiochi::class, '**', 'id');
}
Want results from more Discord servers?
Add your server