1
0
Fork 0

fixed bug acl middleware

fixed bug for any hasAnyAccess
optimized navbar blade
main
A1Gard 1 year 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,8 +154,10 @@
</li>
</ul>
</li>
@endif
@if(auth()->user()->hasAnyAccess('props'))
<li>
<a >
<a>
<i class="fa fa-project-diagram"></i>
{{__("Properties meta")}}
</a>
@ -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,11 +233,12 @@
</li>
@endif
@if(auth()->user()->hasAnyAccess('gallery'))
<li>
<a >
<a>
<i class="fa fa-images"></i>
{{__("Galleries")}}
</a>
@ -237,8 +258,10 @@
</ul>
</li>
@endif
@if(auth()->user()->hasAnyAccess('clip'))
<li>
<a >
<a>
<i class="fa fa-file-video"></i>
{{__("Video clips")}}
</a>
@ -256,8 +279,10 @@
</ul>
</li>
@endif
@if(auth()->user()->hasAnyAccess('adv'))
<li>
<a >
<a>
<i class="fa fa-atom"></i>
{{__("Advertise")}}
</a>
@ -275,14 +300,18 @@
</ul>
</li>
@endif
@if(auth()->user()->hasAnyAccess('menu'))
<li>
<a href="{{route('admin.menu.index')}}" >
<a href="{{route('admin.menu.index')}}">
<i class="fa fa-list-alt"></i>
{{__("Menus")}}
</a>
</li>
@endif
@if(auth()->user()->hasAnyAccess('props'))
<li>
<a >
<a>
<i class="fa fa-file-image"></i>
{{__("Slider")}}
</a>
@ -300,8 +329,10 @@
</ul>
</li>
@endif
@if(auth()->user()->hasAnyAccess('poll'))
<li>
<a >
<a>
<i class="fa fa-vote-yea"></i>
{{__("Poll")}}
</a>
@ -319,42 +350,53 @@
</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 >
<a>
<i class="fa fa-users"></i>
{{__("Users")}}
</a>
@ -374,13 +416,14 @@
</ul>
</li>
@endif
@guest
<li >
<li>
<a href="{{ route('login') }}"> <i class="fa fas fa-sign-in"></i> {{ __('Login') }}</a>
</li>
@if (Route::has('register'))
<li >
<li>
<a href="{{ route('register') }}"> <i class="fa fas fa-sign-in"></i> {{ __('Register') }}</a>
</li>
@endif

Loading…
Cancel
Save