예제 #1
0
파일: Role.php 프로젝트: jjharr/can
 public function hasPermission($permissionSlug)
 {
     $query = DB::table(Config::get('can.role_permission_table'))->where('roles_slug', $this->slug);
     // do this even though we have one permission to get proper wildcard behavior
     $container = new SlugContainer($permissionSlug);
     $query = $container->buildSlugQuery($query, 'permissions_slug');
     $permissions = $query->get();
     return count($permissions) > 0;
 }
예제 #2
0
 /**
  * Return (potentially) multiple roles or permissions using slugs as a key
  *
  * @param $slugs
  *
  * @return array
  */
 public static function many($slugs)
 {
     $query = DB::table(self::$table);
     $container = new SlugContainer($slugs);
     $query = $container->buildSlugQuery($query);
     $hits = $query->distinct()->get();
     return self::hitsToObjects($hits);
 }
예제 #3
0
파일: Can.php 프로젝트: jjharr/can
 /**
  * Determine whether the user has permissions matching the arguments
  *
  * @param $permissions Can be a single fully- or partially-qualified permission, or a pipe-separated list of them
  *
  * @return bool
  */
 public function can($permissions)
 {
     $query = DB::table(Config::get('can.user_permission_table'))->where('user_id', $this->id);
     $container = new SlugContainer($permissions);
     $query = $container->buildSlugQuery($query, 'permissions_slug');
     return count($query->get()) > 0;
 }