Instantly share code, notes, and snippets.
Created
September 27, 2016 12:52
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
Save stormbreakers/2b4949182577d69a7cf3fc96b9a4ff81 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!(Auth::user()->active == 1)) { | |
Auth::logout(); | |
return redirect('sign-in')->with('error', 'Inactive User, Please check with the administrator'); | |
} | |
DB::enableQueryLog(); | |
$currentRouteName = Route::getCurrentRoute()->getName(); | |
$perm = json_decode(Auth::user()->permissions, true); | |
$newMenu = \App\Model\Menus::where('active', '=', '1') | |
->orderBy("sequence", "asc") | |
->orderBy("parent", "asc") | |
->get()->toArray(); | |
$newMenuArray = array(); | |
foreach ($newMenu as $menu) { | |
if ($menu['parent'] == 0) { | |
if (in_array($menu['id'], $perm)) { | |
$newMenuArray[$menu['id']] = array( | |
'id' => $menu['id'], | |
'menu_name' => $menu['menu_name'], | |
'path' => $menu['path'], | |
'icon' => $menu['icon'], | |
'prefix' => $menu['prefix'], | |
'submenu' => [] | |
); | |
} | |
} else { | |
if (isset($newMenuArray[$menu['parent']])) { | |
if (in_array($menu['id'], $perm)) { | |
array_push($newMenuArray[$menu['parent']]['submenu'], array( | |
'id' => $menu['id'], | |
'menu_name' => $menu['menu_name'], | |
'path' => $menu['path'], | |
'prefix' => $menu['prefix'], | |
'icon' => $menu['icon'] | |
) | |
); | |
} | |
} | |
} | |
} | |
$uri = Request::path(); | |
if ($uri == "/" || $uri == "") { | |
$uri = "home"; | |
} | |
$prefixUri = ""; | |
$explodeuri = explode("/", $uri); | |
$prefixUri = $explodeuri[0]; | |
//var_dump($newMenuArray); | |
//exit; | |
?> | |
<!-- .aside --> | |
<aside class="bg-dark lter aside-md hidden-print" id="nav"> | |
<section class="vbox"> | |
<section class="w-f scrollable"> | |
<div class="slim-scroll" data-height="auto" data-disable-fade-out="true" data-distance="0" data-size="5px" | |
data-color="#333333"> | |
<!-- nav --> | |
<nav class="nav-primary hidden-xs"> | |
<ul class="nav main-menu auto-inherit-active-class"> | |
@foreach($newMenuArray as $menus) | |
<li class="{{ ($prefixUri == $menus['prefix']) ? "active" : "" }}"> | |
<a href="{{ ($menus['path'] != "") ? route($menus['path']) : "#" }}" | |
class="{{ ($prefixUri == $menus['prefix']) ? "active" : "" }}"> | |
<i class="fa fa-icon fa-{{ $menus['icon'] }}"> | |
<b class="bg-danger"></b> | |
</i> | |
<span>{{ $menus['menu_name'] }}</span> | |
@if(!empty($menus['submenu'])) | |
<span class="pull-right"> | |
<i class="fa fa-angle-down text"></i> | |
<i class="fa fa-angle-up text-active"></i> | |
</span> | |
@endif | |
</a> | |
@if(!empty($menus['submenu'])) | |
<ul class="nav lt"> | |
@foreach ($menus['submenu'] as $submenus) | |
<li class="{{ ($prefixUri == $submenus['prefix']) ? "active" : "" }}"> | |
<a href="{{ route($submenus['path']) }}" | |
class="{{ ($prefixUri == $submenus['prefix']) ? "active" : "" }}"> | |
<i class="fa fa-angle-right"></i> | |
<span>{{$submenus['menu_name']}}</span> | |
</a> | |
</li> | |
@endforeach | |
</ul> | |
@endif | |
</li> | |
@endforeach | |
</ul> | |
</nav> | |
<!-- / nav --> | |
</div> | |
</section> | |
<footer class="footer lt hidden-xs b-t b-dark"> | |
<a href="#nav" data-toggle="class:nav-xs" class="pull-right btn btn-sm btn-dark btn-icon"> | |
<i class="fa fa-angle-left text"></i> | |
<i class="fa fa-angle-right text-active"></i> | |
</a> | |
</footer> | |
</section> | |
</aside> | |
<!-- /.aside --> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment