Skip to content
Snippets Groups Projects
Select Git revision
  • 7e128a20d56a51be0336a0c40997c0f0f97b284e
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

Form.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    SlotsByBlockIndex.php 1.10 KiB
    <?php
    namespace JsonApi\Routes\Consultations;
    
    use JsonApi\Errors\AuthorizationFailedException;
    use JsonApi\Errors\RecordNotFoundException;
    use JsonApi\JsonApiController;
    use JsonApi\Schemas\ConsultationSlot;
    use Psr\Http\Message\ResponseInterface as Response;
    use Psr\Http\Message\ServerRequestInterface as Request;
    
    class SlotsByBlockIndex extends JsonApiController
    {
        protected $allowedIncludePaths = [
            ConsultationSlot::REL_BLOCK,
            ConsultationSlot::REL_BOOKINGS,
        ];
        protected $allowedPagingParameters = ['offset', 'limit'];
    
        public function __invoke(Request $request, Response $response, $args)
        {
            $block = \ConsultationBlock::find($args['id']);
            if (!$block) {
                throw new RecordNotFoundException();
            }
    
            if (!Authority::canShowBlock($this->getUser($request), $block)) {
                throw new AuthorizationFailedException();
            }
    
            [$offset, $limit] = $this->getOffsetAndLimit();
    
            return $this->getPaginatedContentResponse(
                $block->slots->limit($offset, $limit),
                count($block->slots)
            );
        }
    }