Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ffab's avatar
Level 3

Overall Filter of Resource by a key resource/relations

Hi,

could you please help me to bring this idea to life :)

I have some Users, who belongs to some Clients (my key resource)

My wish would be

  • when a User Logs in in Nova
  • Parse the Clients model, get all the relation set on the client Model
  • Filter all of the Resource (that have relations) with only datas corresponding to theses relations.
  • Only display theses when accessing Nova Resource

What would be the best way to accomplish this kind of things ?

If this i not clear, sorry, i can try to re-phrase if needed.

Regards,

0 likes
3 replies
bugsysha's avatar

Please rephrase it. You are giving a rough overview, which is not that useful.

ffab's avatar
Level 3

Thanks for your advice @bugsysha Doing my rephrase, make me think on my problem again.

In fact all i need is to alter the query of a Nova resource depending on who is looking at the resource

I found my way with adding

public static function indexQuery(NovaRequest $request, $query)
    {
        return $query->whereIn('client_id', $clients)
    }

on my Nova resource class. So it can intercept the query, add some filters and return it back.

Is this the correct way ?

Regards,

Please or to participate in this conversation.