blob: 1d6efc0ea0d8593c2f6ff1e94e9c4e2377dd4935 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
<?php
namespace JsonApi\Routes\Institutes;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use JsonApi\JsonApiController;
use JsonApi\Errors\RecordNotFoundException;
class StatusGroupsOfInstitutes extends JsonApiController
{
protected $allowedIncludePaths = [
'range'
];
protected $allowedPagingParameters = ['offset', 'limit'];
public function __invoke(Request $request, Response $response, $args)
{
if (!$institute = \Institute::find($args['id'])) {
throw new RecordNotFoundException();
}
list($offset, $limit) = $this->getOffsetAndLimit();
$statusGroups = $institute->status_groups;
$total = count($statusGroups);
return $this->getPaginatedContentResponse(
$statusGroups->limit($offset, $limit),
$total
);
}
}
|