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"));
}
// 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';
if (!auth()->user()->hasAccess(implode('.', $requestPath))) {
$requestPath[2] = 'destroy';

@ -101,7 +101,7 @@ class User extends Authenticatable
return $this->hasMany(Access::class);
}
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){

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

Loading…
Cancel
Save