/** * Authorizes an AuthorableInterface instance with * Privileges over selected PrivilegableInterface instance(s). * * @param Agency\Contracts\Cms\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 roleable Agency sections. * * @return Illuminate\Database\Eloquent\Collection */ public function getAgencySections() { return $this->sections->roleable(); }