->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)),
        ];
    }
Solution
You are probably looking for ->whereHas('details', fn ($query) => ...) or a simple join
Was this page helpful?