Closed towerthepower89 closed 6 months ago
Have you registered the policy? Laravel 10.x doesn't auto-register policies, that's a new feature in Laravel 11.x
hi, thank you, indeed it was missing. I updated the version with the policy registration, still the same issue. All the other policies are/were already working, so viewAny, create, delete, update: all of them are correctly applied, but view seems to be skipped.
@towerthepower89 If I understand you correctly you need to add update function to TypePolicy. Because you are trying to edit not view Type entity
https://github.com/filamentphp/filament/assets/4639175/8948b4cc-6867-44a7-aa7e-c8a342dd123f
My end goal would be to hide some rows based on the user group, for example removing RDX and ILX, or all. In the example attached I removed some methods, like delete and update, those have been tested and worked perfectly. From my understanding, by returning false from the view function, no rows should be displayed. Probably I am missing something, thank you for your help.
@towerthepower89 According to the Laravel documentation, the view function determines whether a user can view the model or not. It seems you are trying to filter the row list. I suggest you change your query. Try checking the Customizing the Table Eloquent Query'section and adjust your filter according to the user group.
As for me it's not a filament issue at all.
thank you @dmitry-udod , then we can close the thread :)
Package
filament/filament
Package Version
v3.2.71
Laravel Version
v10.48.9
Livewire Version
v3.4.10
PHP Version
PHP 8.1.0
Problem description
I generated a new policy file using
php artisan make:policy TypePolicy --model=Type
and a new file TypePolicy.php has been generated. During the configuration, the public function view(User $user, Type $type): bool is not being called. Does it have a new name?
Expected behavior
Normally, it should apply a filter in the rows shown in the table, in this case it shows all the records regardless the settings true/false. By checking the logs, it seems the function is never called.
Steps to reproduce
and configure the resource as shown:
Reproduction repository
https://github.com/towerthepower89/filament-issue
Relevant log output
No response