Exemplo n.º 1
0
 /**
  * List ACL collection.
  *
  * @param  object  $listener
  * @param  string  $metric
  *
  * @return mixed
  */
 public function edit($listener, $metric)
 {
     $collection = [];
     $instances = $this->acl->all();
     $eloquent = null;
     foreach ($instances as $name => $instance) {
         $collection[$name] = $this->getAuthorizationName($name);
         $name === $metric && ($eloquent = $instance);
     }
     if (is_null($eloquent)) {
         return $listener->aclVerificationFailed();
     }
     return $listener->indexSucceed(compact('eloquent', 'collection', 'metric'));
 }
Exemplo n.º 2
0
 /**
  * List ACL collection.
  *
  * @param  object  $listener
  * @param  string  $metric
  *
  * @return mixed
  */
 public function edit($listener, $metric)
 {
     $collection = [];
     $instances = $this->acl->all();
     $eloquent = null;
     foreach ($instances as $name => $instance) {
         $collection[$name] = $this->getAuthorizationName($name);
         $name === $metric && ($eloquent = $instance);
     }
     if (is_null($eloquent)) {
         return $listener->aclVerificationFailed();
     }
     $actions = new Collection($eloquent->actions()->get());
     $roles = (new Collection($eloquent->roles()->get()))->reject(function ($role) {
         return in_array($role, ['guest']);
     });
     return $listener->indexSucceed(compact('actions', 'roles', 'eloquent', 'collection', 'metric'));
 }