Write a Gate, e.g.
Gate::define('view_user_interfaces', function (User $user) {
return in_array($user->role, ['admin', 'super_admin']);
});
Then anywhere that needs checking:
// Controller
$this->authorize('view_user_interfaces');
// or
if (auth()->user()->can('view_user_interfaces')) {
// ...
}
// View Template
@can('view_user_interfaces')
<!-- modal button -->
@endcan
This assumes you get the User's role as a string, if working with a Role instance (with a name) then:
return in_array($user->role->name, ['admin', 'super_admin']);