Skip to content
Snippets Groups Projects
Select Git revision
  • b66896cdee96bb2d700383d6b38bbf3c81a9691c
  • main default protected
  • 5.5 protected
  • atlantis
  • 5.3 protected
  • 5.0 protected
  • issue-23
  • issue8-seat-logging-and-export
  • ticket-216
  • tickets-215-216-241-242
10 results

LtiToolModule.class.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)
            );
        }
    }