/** * Authorizes an AuthorableInterface instance with * Privileges over selected PrivilegableInterface instance(s). * * @param Agency\Cms\Authority\Contracts\AuthorableInterface $admin * @param array $Agency * @param array $artists * @return void */ public function authorize(AuthorableInterface $admin, $Agency = [], $artists = []) { // $Agency and $artists must be in the form of ['resource alias' => 'role alias'] $roleable_Agency_sections = $this->Agency_sections->roleable(); // extract matching roleable sections that have been given grants $Agency_sections = $roleable_Agency_sections->filter(function ($section) use($Agency) { return array_key_exists($section->alias(), $Agency); }); $this->resetAuthorization($admin, $roleable_Agency_sections); $this->performAuthorization($admin, $Agency, $Agency_sections); // $artist_sections = $this->artists_sections->initial(array_keys($artists)); // $this->performAuthorization($admin, $artists, $artist_sections); return true; }
/** * Returns the sections that are allowed * for the authenticated admin. * * @return Agency\Cms\Authority\ResourcesCollection */ protected function getAccessibleSections() { $access = Authority::access(Auth::user(), $this->sections->all()); return $access->resources; }