fixed bug acl middleware

fixed bug for any hasAnyAccess
optimized navbar blade
pull/6/head
A1Gard 2 years ago
parent 249a2ed913
commit a44c2f57b9

@ -34,7 +34,7 @@ class Acl
return abort(403, __("You dont't have acccess this acction")); return abort(403, __("You dont't have acccess this acction"));
} }
// check delete or destroy with bulk action // check delete or destroy with bulk action
if ($requestPath[2] == 'bulk' && $request->input('bulk') == 'delete') { if (isset($requestPath[2]) && $requestPath[2] == 'bulk' && $request->input('bulk') == 'delete') {
$requestPath[2] = 'delete'; $requestPath[2] = 'delete';
if (!auth()->user()->hasAccess(implode('.', $requestPath))) { if (!auth()->user()->hasAccess(implode('.', $requestPath))) {
$requestPath[2] = 'destroy'; $requestPath[2] = 'destroy';

@ -101,7 +101,7 @@ class User extends Authenticatable
return $this->hasMany(Access::class); return $this->hasMany(Access::class);
} }
public function hasAnyAccess($name){ public function hasAnyAccess($name){
return $this->accesses()->where('route','LIKE','%'.$name.'%')->count() > 0; return $this->accesses()->where('route','LIKE','%.'.$name.'.%')->count() > 0;
} }
public function hasAccess($route){ public function hasAccess($route){

@ -13,6 +13,7 @@
{{__("Catalog")}} {{__("Catalog")}}
</a> </a>
<ul> <ul>
@if(auth()->user()->hasAnyAccess('product'))
<li id="product-li"> <li id="product-li">
<a> <a>
<i class="fa fa-gem"></i> <i class="fa fa-gem"></i>
@ -31,6 +32,8 @@
</li> </li>
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('invoice'))
<li id="invoices-li"> <li id="invoices-li">
<a> <a>
<i class="fa fa-file-invoice"></i> <i class="fa fa-file-invoice"></i>
@ -49,6 +52,8 @@
</li> </li>
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('customer'))
<li> <li>
<a> <a>
<i class="fa fa-users"></i> <i class="fa fa-users"></i>
@ -67,6 +72,8 @@
</li> </li>
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('discount'))
<li id="discount-li"> <li id="discount-li">
<a> <a>
<i class="fa fa-percent"></i> <i class="fa fa-percent"></i>
@ -85,18 +92,24 @@
</li> </li>
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('question'))
<li id="questions-li"> <li id="questions-li">
<a href="{{route('admin.question.index')}}"> <a href="{{route('admin.question.index')}}">
<i class="fa fa-question"></i> <i class="fa fa-question"></i>
{{__('Questions')}} {{__('Questions')}}
</a> </a>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('ticket'))
<li id="tickets-li"> <li id="tickets-li">
<a href="{{route('admin.ticket.index')}}"> <a href="{{route('admin.ticket.index')}}">
<i class="fa fa-envelope"></i> <i class="fa fa-envelope"></i>
{{__('Tickets')}} {{__('Tickets')}}
</a> </a>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('cat'))
<li> <li>
<a> <a>
<i class="fa fa-cubes"></i> <i class="fa fa-cubes"></i>
@ -120,6 +133,9 @@
</li> </li>
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('transport'))
<li> <li>
<a> <a>
<i class="fa fa-truck"></i> <i class="fa fa-truck"></i>
@ -138,6 +154,8 @@
</li> </li>
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('props'))
<li> <li>
<a> <a>
<i class="fa fa-project-diagram"></i> <i class="fa fa-project-diagram"></i>
@ -157,12 +175,11 @@
</ul> </ul>
</li> </li>
@endif
</ul> </ul>
</li> </li>
<li id="cms" class="main-nav"> <li id="cms" class="main-nav">
<a> <a>
<i class="fab fa-internet-explorer"></i> <i class="fab fa-internet-explorer"></i>
@ -170,6 +187,7 @@
{{__("Website contents")}} {{__("Website contents")}}
</a> </a>
<ul> <ul>
@if(auth()->user()->hasAnyAccess('post'))
<li id="posts-li"> <li id="posts-li">
<a> <a>
<i class="fa fa-bullhorn"></i> <i class="fa fa-bullhorn"></i>
@ -188,6 +206,8 @@
</li> </li>
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('category'))
<li> <li>
<a> <a>
<i class="fa fa-book"></i> <i class="fa fa-book"></i>
@ -213,7 +233,8 @@
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('gallery'))
<li> <li>
@ -237,6 +258,8 @@
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('clip'))
<li> <li>
<a> <a>
<i class="fa fa-file-video"></i> <i class="fa fa-file-video"></i>
@ -256,6 +279,8 @@
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('adv'))
<li> <li>
<a> <a>
<i class="fa fa-atom"></i> <i class="fa fa-atom"></i>
@ -275,12 +300,16 @@
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('menu'))
<li> <li>
<a href="{{route('admin.menu.index')}}"> <a href="{{route('admin.menu.index')}}">
<i class="fa fa-list-alt"></i> <i class="fa fa-list-alt"></i>
{{__("Menus")}} {{__("Menus")}}
</a> </a>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('props'))
<li> <li>
<a> <a>
<i class="fa fa-file-image"></i> <i class="fa fa-file-image"></i>
@ -300,6 +329,8 @@
</ul> </ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('poll'))
<li> <li>
<a> <a>
<i class="fa fa-vote-yea"></i> <i class="fa fa-vote-yea"></i>
@ -319,40 +350,51 @@
</ul> </ul>
</li> </li>
@endif
</ul> </ul>
</li> </li>
@if(auth()->user()->hasAnyAccess('comment'))
<li> <li>
<a href="{{route('admin.comment.index')}}"> <a href="{{route('admin.comment.index')}}">
<i class="fa fa-comments"></i> <i class="fa fa-comments"></i>
{{__('Comments')}} {{__('Comments')}}
</a> </a>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('setting'))
<li> <li>
<a href="{{route('admin.setting.index')}}"> <a href="{{route('admin.setting.index')}}">
<i class="fa fa-cogs"></i> <i class="fa fa-cogs"></i>
{{__("Setting")}} {{__("Setting")}}
</a> </a>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('attachment'))
<li> <li>
<a href="{{route('admin.attachment.index')}}"> <a href="{{route('admin.attachment.index')}}">
<i class="fa fa-paperclip"></i> <i class="fa fa-paperclip"></i>
{{__("Attachments")}} {{__("Attachments")}}
</a> </a>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('contact'))
<li> <li>
<a href="{{route('admin.contact.index')}}"> <a href="{{route('admin.contact.index')}}">
<i class="fa fa-envelope"></i> <i class="fa fa-envelope"></i>
{{__("Contact us")}} {{__("Contact us")}}
</a> </a>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('logs'))
<li> <li>
<a href="{{route('admin.logs.index')}}"> <a href="{{route('admin.logs.index')}}">
<i class="fa fa-list-alt"></i> <i class="fa fa-list-alt"></i>
{{__('Logs')}} {{__('Logs')}}
</a> </a>
</li> </li>
@endif
@if(auth()->user()->hasRole('super-admin'))
<li> <li>
<a> <a>
<i class="fa fa-users"></i> <i class="fa fa-users"></i>
@ -374,6 +416,7 @@
</ul> </ul>
</li> </li>
@endif
@guest @guest
<li> <li>

Loading…
Cancel
Save