Example #1
0
 /**
  * Create a privilege for the authorable as $role on $resource.
  *
  * @param  Agency\Cms\Auth\Authorization\Entities\Role $role
  * @param  mixed $resource Can be any reference to the resource or the resource itself.
  * @param  array $attributes
  * @return Agency\Cms\Auth\Authorization\Entities\Privilege
  */
 protected function createPrivilege(Role $role, $resource, $attributes = [], $for_artists)
 {
     $section = 'section';
     return Privilege::createWith($attributes, ['admin' => $this->authorable->getKey(), 'role' => $role, $section => $resource]);
 }
Example #2
0
 /**
  * Get all the privileges of a given authorable.
  *
  * @param  Agency\Contracts\Cms\AuthorableInterface $authorable
  * @return Illuminate\Database\Eloquent\Collection
  */
 protected function all(AuthorableInterface $authorable)
 {
     return Privilege::with($this->with)->whereHas('admin', function ($q) use($authorable) {
         $q->where('id', $authorable->getKey());
     })->get();
 }
Example #3
0
 public function __construct(AuthorableInterface $authorable, $resources)
 {
     $resource_types = $this->extractResourceTypes($resources);
     $previous = Privilege::where('admin_id', $authorable->getKey())->whereIn('resource_type', $resource_types)->delete();
 }