/** * 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"]); }
/** * 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"]); }