Show Users with role as User only
So I made a default User and I just added a few users, and my table in Database has a field called role in it and I only want to show the users that have that role field as User, I am not sure how I would do it.
Basically is there a way to run this query in Filament
"SELECT * FROM users WHERE role='User'"
5 Replies
where you want to call that query? do you have a full resource or customer table or widget or filter... π
there is
->query()
that you can change it to what you likeBasically, like let's say I have the table Users and I made a page with Filament, it is showing me all the Users in my table, I haven't done any query on Laravel end as well, so its a basic default table so I want to query in Filament page, and not show other Admin users
Thanks for the reply and sorry I am kind of new to this so I have no idea.
Solution
so you can start with
there is other options too, like using filters and more
check this for more
https://filamentphp.com/docs/3.x/panels/resources/listing-records
and you can do
User::query()->where('..','..')
but I recommend you give the filters a try πYeah I will use Filters for the other things like its basically for Sports, so I will use filters for different sports
Thank you so much, it worked!!
Really appreciate it!