blob: 31df647ecad1fe6f606bd0658f945558db7e89e0 (
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
|
<?php
namespace JsonApi\Routes\Consultations;
use JsonApi\Errors\AuthorizationFailedException;
use JsonApi\Errors\RecordNotFoundException;
use JsonApi\JsonApiController;
use JsonApi\Schemas\ConsultationBooking;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
class BookingsShow extends JsonApiController
{
protected $allowedIncludePaths = [
ConsultationBooking::REL_SLOT,
ConsultationBooking::REL_USER,
];
public function __invoke(Request $request, Response $response, $args)
{
$booking = \ConsultationBooking::find($args['id']);
if (!$booking) {
throw new RecordNotFoundException();
}
if (!Authority::canShowBooking($this->getUser($request), $booking)) {
throw new AuthorizationFailedException();
}
return $this->getContentResponse($booking);
}
}
|