/** * @param \Agency\Contracts\Cms\Repositories\SectionRepositoryInterface $sections * @param \Agency\Contracts\NewsServiceInterface $news_service * @param \Agency\Contracts\WriterRepositoryInterface $writers * @param \Agency\Contracts\NewsValidatorInterface $news_validator * @param \Agency\Contracts\PhotosServiceInterface $photos_service * @param \Agency\Contracts\ContentServiceInterface $content_service * @param \Agency\Contracts\HelperInterface $helper */ public function __construct(SectionRepositoryInterface $sections, NewsServiceInterface $news_service, WriterRepositoryInterface $writers, NewsValidatorInterface $news_validator, PhotosServiceInterface $photos_service, ContentServiceInterface $content_service, HelperInterface $helper) { parent::__construct(); $this->sections = $sections; $this->news_service = $news_service; $this->writers = $writers; $this->news_validator = $news_validator; $this->photos_service = $photos_service; $this->content_service = $content_service; $this->helper = $helper; $this->section = $this->sections->findBy("alias", self::NEWS_ALIAS); }
/** * 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; }
/** * check if input exist then prepare the relation object and assign it to the array * * @param $relations * * @return array */ public function sectionRelations($relations) { $result = []; // prepare relations: if (isset($relations['section'])) { $result = ['section' => $this->sections->findBy('alias', $relations['section'])]; } return $result; }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { if (Auth::hasPermission('delete')) { try { $this->sections->remove($id); } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) { $error = Lang::get('errors.section_not_found'); return Response::json(compact('error'), 404); } } }
/** * Returns the roleable Agency sections. * * @return Illuminate\Database\Eloquent\Collection */ public function getAgencySections() { return $this->sections->roleable(); }
public function children() { return $this->sections->infertile(); }