/** * @api {get} /users/{username}/images Get User's Images * @apiGroup Users * @apiDescription Gets images uploaded by a user. The results are paginated with 15 results per page. * @apiParam {string} [sessionKey] A session key belonging to this user. Unless this is given anonymous * and passworded images will be omitted. * @apiParam {int} [page=1] Results page number. * @apiUse PaginatedImageResponse * * @param User $user * * @return Response */ public function indexImages(User $user) { $this->validate($this->request, ['page' => 'int|min:1']); $results = $user->images()->with('imageFile')->with('thumbnailImageFile'); if (!$this->isCurrentUser($user->getId())) { $results->where('anonymous', 0)->whereNull('password'); } $results->orderBy('imageId', 'DESC'); $paginator = $results->paginate($this->getResultsPerPage()); return $this->response($this->paginatorToArray($paginator, 'images')); }