lundi 10 juillet 2017

Show different navigation for different users role

I'm building an app where I have to show different navigation for users role. However, this is what I've came up with

Navigation example :

<div id="navbar" class="navbar-collapse collapse">
    <ul class="nav navbar-nav navbar-right">
       @if (Auth::check() && Auth::user()->role == 'author')
       <li><a href=""><i class="fa fa-user"></i> </a></li>
       @endif

       @if (Auth::check() && Auth::user()->role == 'admin')
         @if (!empty($page) && $page == 'admin')
           <li class="active"><a href=""><i class="fa fa-user"></i> Admin</a></li>
         @else
           <li><a href=""><i class="fa fa-user"></i> Admin</a></li>
         @endif
       @endif

       @if (Auth::check())
       <li><a href=""><i class="fa fa-sign-out"></i> Logout</a></li>
       @else
          @if (!empty($page) && $page == 'login')
             <li class="active"><a href=""><i class="fa fa-sign-in"></i> Login</a></li>
          @else
             <li><a href=""><i class="fa fa-sign-in"></i> Login</a></li>
          @endif
       @endif
   </ul>   
 </div><!--/.nav-collapse -->

I've tested it and it works just fine, but I'm just wondering if this will affect the app performance, making it slow ? If so is there a better way to do this ? That's all and thanks!



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

Aucun commentaire:

Enregistrer un commentaire