Exemplo n.º 1
0
 /**
  * @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);
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * 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);
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Returns the roleable Agency sections.
  *
  * @return Illuminate\Database\Eloquent\Collection
  */
 public function getAgencySections()
 {
     return $this->sections->roleable();
 }
Exemplo n.º 6
0
 public function children()
 {
     return $this->sections->infertile();
 }