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")); 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,8 +154,10 @@
</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>
{{__("Properties meta")}} {{__("Properties meta")}}
</a> </a>
@ -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,11 +233,12 @@
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('gallery'))
<li> <li>
<a > <a>
<i class="fa fa-images"></i> <i class="fa fa-images"></i>
{{__("Galleries")}} {{__("Galleries")}}
</a> </a>
@ -237,8 +258,10 @@
</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>
{{__("Video clips")}} {{__("Video clips")}}
</a> </a>
@ -256,8 +279,10 @@
</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>
{{__("Advertise")}} {{__("Advertise")}}
</a> </a>
@ -275,14 +300,18 @@
</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>
{{__("Slider")}} {{__("Slider")}}
</a> </a>
@ -300,8 +329,10 @@
</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>
{{__("Poll")}} {{__("Poll")}}
</a> </a>
@ -319,42 +350,53 @@
</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>
{{__("Users")}} {{__("Users")}}
</a> </a>
@ -374,13 +416,14 @@
</ul> </ul>
</li> </li>
@endif
@guest @guest
<li > <li>
<a href="{{ route('login') }}"> <i class="fa fas fa-sign-in"></i> {{ __('Login') }}</a> <a href="{{ route('login') }}"> <i class="fa fas fa-sign-in"></i> {{ __('Login') }}</a>
</li> </li>
@if (Route::has('register')) @if (Route::has('register'))
<li > <li>
<a href="{{ route('register') }}"> <i class="fa fas fa-sign-in"></i> {{ __('Register') }}</a> <a href="{{ route('register') }}"> <i class="fa fas fa-sign-in"></i> {{ __('Register') }}</a>
</li> </li>
@endif @endif

Loading…
Cancel
Save