How to permanently filter table

I think my question is quite simple: I have a table invoices that I'll link to a resource. but I want to filter the table so that the currently authenticated user can only see/edit/create invoices that are associated with him. So this is not a filter that the user can control
Solution:
Use the ->query() method on the $table instance. Here’s an example:
->query(MyModel::query()->orderBy('time', 'desc')->limit(100))
->query(MyModel::query()->orderBy('time', 'desc')->limit(100))
...
Jump to solution
8 Replies
Solution
slooffmaster
slooffmaster13mo ago
Use the ->query() method on the $table instance. Here’s an example:
->query(MyModel::query()->orderBy('time', 'desc')->limit(100))
->query(MyModel::query()->orderBy('time', 'desc')->limit(100))
King Dice
King DiceOP13mo ago
any idea what's the difference between ->query and ->modifyQueryUsing that's in the docs?
slooffmaster
slooffmaster13mo ago
I actually didn’t dive into this; I found the method in the source of the Table class.
King Dice
King DiceOP13mo ago
sounds good, thanks for the help!
slooffmaster
slooffmaster13mo ago
👍
Kenneth Sese
Kenneth Sese13mo ago
They both do the same thing, but the core team has been moving more towards the using pattern. Here’s some discussion: https://github.com/filamentphp/filament/pull/9293#issuecomment-1781417555
GitHub
New table filters indicator API by zepfietje · Pull Request #9293 ·...
Changes have been thoroughly tested to not break existing functionality. New functionality has been documented or existing documentation has been updated to reflect changes. Visual changes are ex...
slooffmaster
slooffmaster13mo ago
👍
Want results from more Discord servers?
Add your server