예제 #1
0
 /**
  * Can at least blade directive compiler.
  *
  * @param string|array $permissions
  * @return bool
  * @throws \Exception
  * @throws \Throwable
  */
 public function handle($permissions)
 {
     if (auth()->check()) {
         return auth()->user()->canAtLeast((array) $permissions);
     } else {
         $guest = Role::whereSlug('guest')->first();
         if ($guest) {
             return $guest->canAtLeast((array) $permissions);
         }
     }
     return false;
 }
예제 #2
0
 /**
  * Check if user has at least one of the given permissions
  *
  * @param  array $permissions
  * @return bool
  */
 public function canAtLeast(array $permissions)
 {
     $can = false;
     if (auth()->check()) {
         foreach ($this->roles as $role) {
             if ($role->canAtLeast($permissions)) {
                 $can = true;
             }
         }
     } else {
         $guest = Role::whereSlug('guest')->first();
         if ($guest) {
             return $guest->canAtLeast($permissions);
         }
     }
     return $can;
 }