I made this custom Laravel blade directive that checks with user role. I want to see if a user is either an admin or owner. Is there a way to do something like that -
@IsAdmin || @IsOwner
<h1>Test</h1>
@endIsAdmin @endIsOwner
And here's my implementation of Blade directives implementation-
$roles = Rolelabel::get();
foreach ($roles as $value) {
Blade::if('Is'.$value->label, function() use($value){
return (int)auth()->user()->role == (int)$value->id;
});
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire