/** * Return the artist's roles. * @param array $ids * @return mixed */ public function forArtists($ids = []) { if (empty($ids)) { return $this->role->where('for_artists', true)->get(); } return $this->role->whereIn($ids)->get(); }
/** * Grant a role for an AuthorableInterface over a resource. * * @todo Improve to accept authorization for multiple resources. * * @param string $role_alias The role to grant * @param mixed $resource You can send out anything that represents a resource, or the resource itself. * @return Agency\Cms\Auth\Authorization\Entities\Privilege */ public function grant($role_alias, $resources, $for_artists = null) { // Check the validity of the claimed role $role = Role::where('alias', $role_alias)->where('for_artists', $for_artists)->first(); if (!$role) { throw new Exceptions\RoleNotFoundException($role_alias); } // In case the passed resources is not an iterable type we make it an array // so that we work with them in one way, not much of an overhead here anyway... if (!is_array($resources) && !$resources instanceof Collection) { $resources = [$resources]; } return $this->createAndUpdate($role, $resources, $for_artists); }