diff --git a/app/Http/Middleware/Acl.php b/app/Http/Middleware/Acl.php index 69aefb2..facc859 100644 --- a/app/Http/Middleware/Acl.php +++ b/app/Http/Middleware/Acl.php @@ -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'; diff --git a/app/Models/User.php b/app/Models/User.php index 3c6a9ed..296c6cc 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -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){ diff --git a/resources/views/vendor/starter-kit/component/navbar.blade.php b/resources/views/vendor/starter-kit/component/navbar.blade.php index 5509e3a..6d1f477 100755 --- a/resources/views/vendor/starter-kit/component/navbar.blade.php +++ b/resources/views/vendor/starter-kit/component/navbar.blade.php @@ -13,156 +13,173 @@ {{__("Catalog")}} - - -
  • - - - {{__('Comments')}} - -
  • -
  • - - - {{__("Setting")}} - -
  • -
  • - - - {{__("Attachments")}} - -
  • -
  • - - - {{__("Contact us")}} - -
  • -
  • - - - {{__('Logs')}} - -
  • - -
  • - - - {{__("Users")}} - - + @if(auth()->user()->hasAnyAccess('comment')) +
  • + + + {{__('Comments')}} + +
  • + @endif + @if(auth()->user()->hasAnyAccess('setting')) +
  • + + + {{__("Setting")}} + +
  • + @endif + @if(auth()->user()->hasAnyAccess('attachment')) +
  • + + + {{__("Attachments")}} + +
  • + @endif + @if(auth()->user()->hasAnyAccess('contact')) +
  • + + + {{__("Contact us")}} + +
  • + @endif + @if(auth()->user()->hasAnyAccess('logs')) +
  • + + + {{__('Logs')}} + +
  • + @endif + @if(auth()->user()->hasRole('super-admin')) +
  • + + + {{__("Users")}} + + -
  • + + @endif @guest -
  • +
  • {{ __('Login') }}
  • @if (Route::has('register')) -
  • +
  • {{ __('Register') }}
  • @endif