F
Filament14mo ago
Pasteko

->modifyQueryUsing with relations

Hello, I need to use a 'details' relation to query the state, how can I do this? Tried to add ->with('details') or -details(), please help. $query->with('details')->where('state', 1)) $query->details()->where('state', 1)) Thanks
public function getTabs(): array
{
return [
'enabled' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->where('state', 1)),
'all' => Tab::make(),
'disabled' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->where('state', 0)),
];
}
public function getTabs(): array
{
return [
'enabled' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->where('state', 1)),
'all' => Tab::make(),
'disabled' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->where('state', 0)),
];
}
Solution:
You are probably looking for ->whereHas('details', fn ($query) => ...) or a simple join
Jump to solution
2 Replies
Solution
Dennis Koch
Dennis Koch14mo ago
You are probably looking for ->whereHas('details', fn ($query) => ...) or a simple join
Pasteko
PastekoOP14mo ago
Thank you, it's working!
Want results from more Discord servers?
Add your server