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,156 +13,173 @@
{{__("Catalog")}} {{__("Catalog")}}
</a> </a>
<ul> <ul>
<li id="product-li"> @if(auth()->user()->hasAnyAccess('product'))
<a> <li id="product-li">
<i class="fa fa-gem"></i> <a>
{{__('Products')}} <i class="fa fa-gem"></i>
</a> {{__('Products')}}
<ul> </a>
<li> <ul>
<a href="{{route('admin.product.index')}}"> <li>
{{__('Products list')}} <a href="{{route('admin.product.index')}}">
</a> {{__('Products list')}}
</li> </a>
<li> </li>
<a href="{{route('admin.product.create')}}"> <li>
{{__('New Product')}} <a href="{{route('admin.product.create')}}">
</a> {{__('New Product')}}
</li> </a>
</ul> </li>
</li> </ul>
<li id="invoices-li"> </li>
<a> @endif
<i class="fa fa-file-invoice"></i> @if(auth()->user()->hasAnyAccess('invoice'))
{{__('Invoices')}} <li id="invoices-li">
</a> <a>
<ul> <i class="fa fa-file-invoice"></i>
<li> {{__('Invoices')}}
<a href="{{route('admin.invoice.index')}}"> </a>
{{__('Invoices list')}} <ul>
</a> <li>
</li> <a href="{{route('admin.invoice.index')}}">
<li> {{__('Invoices list')}}
<a href="{{route('admin.invoice.create')}}"> </a>
{{__('New Invoice')}} </li>
</a> <li>
</li> <a href="{{route('admin.invoice.create')}}">
</ul> {{__('New Invoice')}}
</li> </a>
<li> </li>
<a> </ul>
<i class="fa fa-users"></i> </li>
{{__('Customers')}} @endif
</a> @if(auth()->user()->hasAnyAccess('customer'))
<ul> <li>
<li> <a>
<a href="{{route('admin.customer.index')}}"> <i class="fa fa-users"></i>
{{__('Customers list')}} {{__('Customers')}}
</a> </a>
</li> <ul>
<li> <li>
<a href="{{route('admin.customer.create')}}"> <a href="{{route('admin.customer.index')}}">
{{__('New Customer')}} {{__('Customers list')}}
</a> </a>
</li> </li>
</ul> <li>
</li> <a href="{{route('admin.customer.create')}}">
<li id="discount-li"> {{__('New Customer')}}
<a> </a>
<i class="fa fa-percent"></i> </li>
{{__('Discounts')}} </ul>
</a> </li>
<ul> @endif
<li> @if(auth()->user()->hasAnyAccess('discount'))
<a href="{{route('admin.discount.index')}}"> <li id="discount-li">
{{__('Discounts list')}} <a>
</a> <i class="fa fa-percent"></i>
</li> {{__('Discounts')}}
<li> </a>
<a href="{{route('admin.discount.create')}}"> <ul>
{{__('New discount')}} <li>
</a> <a href="{{route('admin.discount.index')}}">
</li> {{__('Discounts list')}}
</ul> </a>
</li> </li>
<li id="questions-li"> <li>
<a href="{{route('admin.question.index')}}"> <a href="{{route('admin.discount.create')}}">
<i class="fa fa-question"></i> {{__('New discount')}}
{{__('Questions')}} </a>
</a> </li>
</li> </ul>
<li id="tickets-li"> </li>
<a href="{{route('admin.ticket.index')}}"> @endif
<i class="fa fa-envelope"></i> @if(auth()->user()->hasAnyAccess('question'))
{{__('Tickets')}} <li id="questions-li">
</a> <a href="{{route('admin.question.index')}}">
</li> <i class="fa fa-question"></i>
<li> {{__('Questions')}}
<a> </a>
<i class="fa fa-cubes"></i> </li>
{{__('Product categories')}} @endif
</a> @if(auth()->user()->hasAnyAccess('ticket'))
<ul> <li id="tickets-li">
<li> <a href="{{route('admin.ticket.index')}}">
<a href="{{route('admin.cat.index')}}"> <i class="fa fa-envelope"></i>
{{__('Product categories list')}} {{__('Tickets')}}
</a> </a>
</li> </li>
<li> @endif
<a href="{{route('admin.cat.create')}}"> @if(auth()->user()->hasAnyAccess('cat'))
{{__('New Product category')}} <li>
</a> <a>
</li> <i class="fa fa-cubes"></i>
<li> {{__('Product categories')}}
<a href="{{route('admin.cat.sort')}}"> </a>
{{__('Product categories node')}} <ul>
</a> <li>
</li> <a href="{{route('admin.cat.index')}}">
</ul> {{__('Product categories list')}}
</li> </a>
<li> </li>
<a> <li>
<i class="fa fa-truck"></i> <a href="{{route('admin.cat.create')}}">
{{__('Transports')}} {{__('New Product category')}}
</a> </a>
<ul> </li>
<li> <li>
<a href="{{route('admin.transport.index')}}"> <a href="{{route('admin.cat.sort')}}">
{{__('Transports list')}} {{__('Product categories node')}}
</a> </a>
</li> </li>
<li> </ul>
<a href="{{route('admin.transport.create')}}"> </li>
{{__('New transport')}} @endif
</a> @if(auth()->user()->hasAnyAccess('transport'))
</li>
</ul>
</li>
<li>
<a >
<i class="fa fa-project-diagram"></i>
{{__("Properties meta")}}
</a>
<ul>
<li>
<a href="{{route('admin.props.index')}}">
{{__("Properties list")}}
</a>
</li>
<li>
<a href="{{route('admin.props.create')}}">
{{__("New Property")}}
</a>
</li>
</ul>
</li> <li>
<a>
<i class="fa fa-truck"></i>
{{__('Transports')}}
</a>
<ul>
<li>
<a href="{{route('admin.transport.index')}}">
{{__('Transports list')}}
</a>
</li>
<li>
<a href="{{route('admin.transport.create')}}">
{{__('New transport')}}
</a>
</li>
</ul>
</li>
@endif
@if(auth()->user()->hasAnyAccess('props'))
<li>
<a>
<i class="fa fa-project-diagram"></i>
{{__("Properties meta")}}
</a>
<ul>
<li>
<a href="{{route('admin.props.index')}}">
{{__("Properties list")}}
</a>
</li>
<li>
<a href="{{route('admin.props.create')}}">
{{__("New Property")}}
</a>
</li>
</ul>
</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,217 +187,243 @@
{{__("Website contents")}} {{__("Website contents")}}
</a> </a>
<ul> <ul>
<li id="posts-li"> @if(auth()->user()->hasAnyAccess('post'))
<a> <li id="posts-li">
<i class="fa fa-bullhorn"></i> <a>
{{__('Post')}} <i class="fa fa-bullhorn"></i>
</a> {{__('Post')}}
<ul> </a>
<li> <ul>
<a href="{{route('admin.post.index')}}"> <li>
{{__('Post list')}} <a href="{{route('admin.post.index')}}">
</a> {{__('Post list')}}
</li> </a>
<li> </li>
<a href="{{route('admin.post.create')}}"> <li>
{{__('New Post')}} <a href="{{route('admin.post.create')}}">
</a> {{__('New Post')}}
</li> </a>
</ul> </li>
</li> </ul>
<li> </li>
<a> @endif
<i class="fa fa-book"></i> @if(auth()->user()->hasAnyAccess('category'))
{{__('Categories')}} <li>
</a> <a>
<ul> <i class="fa fa-book"></i>
<li> {{__('Categories')}}
<a href="{{route('admin.category.index')}}"> </a>
{{__('Categories list')}} <ul>
</a> <li>
</li> <a href="{{route('admin.category.index')}}">
<li> {{__('Categories list')}}
<a href="{{route('admin.category.create')}}"> </a>
{{__('New category')}} </li>
</a> <li>
</li> <a href="{{route('admin.category.create')}}">
<li> {{__('New category')}}
<a href="{{route('admin.category.sort')}}"> </a>
{{__('Categories node')}} </li>
</a> <li>
</li> <a href="{{route('admin.category.sort')}}">
</ul> {{__('Categories node')}}
</a>
</li>
</ul>
</li> </li>
@endif
@if(auth()->user()->hasAnyAccess('gallery'))
<li>
<a>
<i class="fa fa-images"></i>
{{__("Galleries")}}
</a>
<ul>
<li>
<a href="{{route('admin.gallery.all')}}">
{{-- <i class="fa fa-list-alt"></i> --}}
{{__("Gallery list")}}
</a>
</li>
<li>
<a href="{{route('admin.gallery.create')}}">
{{-- <i class="fa fa-plus-square"></i>--}}
{{__("New gallery")}}
</a>
</li>
</ul>
<li> </li>
<a > @endif
<i class="fa fa-images"></i> @if(auth()->user()->hasAnyAccess('clip'))
{{__("Galleries")}} <li>
</a> <a>
<ul> <i class="fa fa-file-video"></i>
<li> {{__("Video clips")}}
<a href="{{route('admin.gallery.all')}}"> </a>
{{-- <i class="fa fa-list-alt"></i> --}} <ul>
{{__("Gallery list")}} <li>
</a> <a href="{{route('admin.clip.index')}}">
</li> {{__("Video list")}}
<li> </a>
<a href="{{route('admin.gallery.create')}}"> </li>
{{-- <i class="fa fa-plus-square"></i>--}} <li>
{{__("New gallery")}} <a href="{{route('admin.clip.create')}}">
</a> {{__("New Video")}}
</li> </a>
</ul> </li>
</ul>
</li> </li>
<li> @endif
<a > @if(auth()->user()->hasAnyAccess('adv'))
<i class="fa fa-file-video"></i> <li>
{{__("Video clips")}} <a>
</a> <i class="fa fa-atom"></i>
<ul> {{__("Advertise")}}
<li> </a>
<a href="{{route('admin.clip.index')}}"> <ul>
{{__("Video list")}} <li>
</a> <a href="{{route('admin.adv.index')}}">
</li> {{__("Advertise list")}}
<li> </a>
<a href="{{route('admin.clip.create')}}"> </li>
{{__("New Video")}} <li>
</a> <a href="{{route('admin.adv.create')}}">
</li> {{__("New Advertise")}}
</ul> </a>
</li>
</ul>
</li> </li>
<li> @endif
<a > @if(auth()->user()->hasAnyAccess('menu'))
<i class="fa fa-atom"></i> <li>
{{__("Advertise")}} <a href="{{route('admin.menu.index')}}">
</a> <i class="fa fa-list-alt"></i>
<ul> {{__("Menus")}}
<li> </a>
<a href="{{route('admin.adv.index')}}"> </li>
{{__("Advertise list")}} @endif
</a> @if(auth()->user()->hasAnyAccess('props'))
</li> <li>
<li> <a>
<a href="{{route('admin.adv.create')}}"> <i class="fa fa-file-image"></i>
{{__("New Advertise")}} {{__("Slider")}}
</a> </a>
</li> <ul>
</ul> <li>
<a href="{{route('admin.slider.index')}}">
{{__("Slider list")}}
</a>
</li>
<li>
<a href="{{route('admin.slider.create')}}">
{{__("New Slider")}}
</a>
</li>
</ul>
</li> </li>
<li> @endif
<a href="{{route('admin.menu.index')}}" > @if(auth()->user()->hasAnyAccess('poll'))
<i class="fa fa-list-alt"></i> <li>
{{__("Menus")}} <a>
</a> <i class="fa fa-vote-yea"></i>
</li> {{__("Poll")}}
<li> </a>
<a > <ul>
<i class="fa fa-file-image"></i> <li>
{{__("Slider")}} <a href="{{route('admin.poll.index')}}">
</a> {{__("Polls list")}}
<ul> </a>
<li> </li>
<a href="{{route('admin.slider.index')}}"> <li>
{{__("Slider list")}} <a href="{{route('admin.poll.create')}}">
</a> {{__("New Poll")}}
</li> </a>
<li> </li>
<a href="{{route('admin.slider.create')}}"> </ul>
{{__("New Slider")}}
</a>
</li>
</ul>
</li> </li>
<li> @endif
<a >
<i class="fa fa-vote-yea"></i>
{{__("Poll")}}
</a>
<ul>
<li>
<a href="{{route('admin.poll.index')}}">
{{__("Polls list")}}
</a>
</li>
<li>
<a href="{{route('admin.poll.create')}}">
{{__("New Poll")}}
</a>
</li>
</ul>
</li>
</ul> </ul>
</li> </li>
<li> @if(auth()->user()->hasAnyAccess('comment'))
<a href="{{route('admin.comment.index')}}"> <li>
<i class="fa fa-comments"></i> <a href="{{route('admin.comment.index')}}">
{{__('Comments')}} <i class="fa fa-comments"></i>
</a> {{__('Comments')}}
</li> </a>
<li> </li>
<a href="{{route('admin.setting.index')}}"> @endif
<i class="fa fa-cogs"></i> @if(auth()->user()->hasAnyAccess('setting'))
{{__("Setting")}} <li>
</a> <a href="{{route('admin.setting.index')}}">
</li> <i class="fa fa-cogs"></i>
<li> {{__("Setting")}}
<a href="{{route('admin.attachment.index')}}"> </a>
<i class="fa fa-paperclip"></i> </li>
{{__("Attachments")}} @endif
</a> @if(auth()->user()->hasAnyAccess('attachment'))
</li> <li>
<li> <a href="{{route('admin.attachment.index')}}">
<a href="{{route('admin.contact.index')}}"> <i class="fa fa-paperclip"></i>
<i class="fa fa-envelope"></i> {{__("Attachments")}}
{{__("Contact us")}} </a>
</a> </li>
</li> @endif
<li> @if(auth()->user()->hasAnyAccess('contact'))
<a href="{{route('admin.logs.index')}}"> <li>
<i class="fa fa-list-alt"></i> <a href="{{route('admin.contact.index')}}">
{{__('Logs')}} <i class="fa fa-envelope"></i>
</a> {{__("Contact us")}}
</li> </a>
</li>
<li> @endif
<a > @if(auth()->user()->hasAnyAccess('logs'))
<i class="fa fa-users"></i> <li>
{{__("Users")}} <a href="{{route('admin.logs.index')}}">
</a> <i class="fa fa-list-alt"></i>
<ul> {{__('Logs')}}
<li> </a>
<a href="{{route('admin.user.all')}}"> </li>
{{-- <i class="fa fa-list-alt"></i> --}} @endif
{{__("Users list")}} @if(auth()->user()->hasRole('super-admin'))
</a> <li>
</li> <a>
<li> <i class="fa fa-users"></i>
<a href="{{route('admin.user.create')}}"> {{__("Users")}}
{{-- <i class="fa fa-plus-square"></i>--}} </a>
{{__("New user")}} <ul>
</a> <li>
</li> <a href="{{route('admin.user.all')}}">
</ul> {{-- <i class="fa fa-list-alt"></i> --}}
{{__("Users list")}}
</a>
</li>
<li>
<a href="{{route('admin.user.create')}}">
{{-- <i class="fa fa-plus-square"></i>--}}
{{__("New user")}}
</a>
</li>
</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