mercredi 13 juin 2018

Combine multiple blade directives with conditional operators in Laravel?

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;
        });
    }



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2JHJUXt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire