F
Filament12mo ago
Sidem

problem mount

i use this in my Ressource page but but when I log in with account "D" on the OldRequest page, nothing happens, the user can navigate the page (even though he shouldn't)
class OldRequest extends Resource {

public function mount(): void{
abort_unless(auth()->user()->roles()->whereIn('name', ['D'])->exists(), 403); // auth()->user()->roles()->whereIn('name', ['D']->exists() : return true or false
$this->fillForm();
}

......
}
class OldRequest extends Resource {

public function mount(): void{
abort_unless(auth()->user()->roles()->whereIn('name', ['D'])->exists(), 403); // auth()->user()->roles()->whereIn('name', ['D']->exists() : return true or false
$this->fillForm();
}

......
}
if you have any ideas I'm interested
2 Replies
LeandroFerreira
LeandroFerreira12mo ago
You should use policies https://filamentphp.com/docs/3.x/panels/resources/getting-started#authorization If you want to use the mount method, you should use it in the resource pages, as ListPage, CreatePage, etc
Sidem
SidemOP12mo ago
no i can't because i have an other Ressource Page who use the same model
Want results from more Discord servers?
Add your server