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

KikoLdasd's avatar

How to use spatie roles permissions by user auth roles

Hi, is there a way to use the logged in user roles directly in the constructor by using spatie roles? https://spatie.be/docs/laravel-permission/v5/basic-usage/middleware#breadcrumb for example

public function __construct()
{
    $this->middleware(['role_or_permission:{auth()->user()->role->permissions}']);
}

I mean if I could separate the roles and put them directly for the logged in user and make a class to extend them to not put manually for each For example, to inherit this from the Controller function and extend them to each controller separately

0 likes
1 reply

Please or to participate in this conversation.