diff options
Diffstat (limited to 'lib/classes/JsonApi/Routes/Resources/ResourceBookingIntervalShow.php')
| -rw-r--r-- | lib/classes/JsonApi/Routes/Resources/ResourceBookingIntervalShow.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/classes/JsonApi/Routes/Resources/ResourceBookingIntervalShow.php b/lib/classes/JsonApi/Routes/Resources/ResourceBookingIntervalShow.php new file mode 100644 index 0000000..b561b42 --- /dev/null +++ b/lib/classes/JsonApi/Routes/Resources/ResourceBookingIntervalShow.php @@ -0,0 +1,27 @@ +<?php +namespace JsonApi\Routes\Resources; + +use JsonApi\Schemas\ResourceBookingIntervalSchema; +use JsonApi\Errors\RecordNotFoundException; +use JsonApi\JsonApiController; +use Psr\Http\Message\RequestInterface as Request; +use Psr\Http\Message\ResponseInterface as Response; +use ResourceBookingInterval; + +final class ResourceBookingIntervalShow extends JsonApiController +{ + protected $allowedIncludePaths = [ + ResourceBookingIntervalSchema::REL_BOOKING, + ResourceBookingIntervalSchema::REL_RESOURCE, + ]; + + public function __invoke(Request $request, Response $response, array $args): Response + { + $interval = ResourceBookingInterval::find($args['id']); + if (!$interval) { + throw new RecordNotFoundException("No booking interval with the id {$args['id']}"); + } + + return $this->getContentResponse($interval); + } +} |
