Exemplo n.º 1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Eos\Http\Response\Format\JsonApi
  */
 public function index()
 {
     $user = $this->user();
     if ($user == null) {
         throw new UnauthorizedHttpException("Bearer", "You are not authorized to see all permissions.", null, 0xc00401);
     }
     if (!policy(Permission::class)->canSeeAll($user)) {
         throw new HttpException(403, "You are not authorized to see all permissions.", null, [], 0xc00402);
     }
     $permissions = $this->repository->all();
     return $this->response->collection($permissions, new PermissionTransformer(), ["key" => "permissions"]);
 }
Exemplo n.º 2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Eos\Http\Response\Format\JsonApi
  */
 public function index()
 {
     $user = $this->user();
     //    if ($user == null) {
     //      throw new UnauthorizedHttpException("Bearer", "You are not authorized to see all users.", null, 0x00C00301);
     //    }
     if (!policy($user)->canSeeAll($user)) {
         throw new HttpException(403, "You are not authorized to see all users.", null, [], 0xc00302);
     }
     $users = $this->repository->all();
     return $this->response->collection($users, new UserTransformer(), ["key" => "users"]);
 }