Commit 1b802653 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Add pagination to a route that was missing it

parent bf0acfd5
......@@ -90,6 +90,7 @@ class GroupScheduleController extends ApiController
* This endpoint returns all schedules that a specified group is attached to.
*
* @authenticated
* @paginated
* @urlParam groupId required The id of the group to get the schedules for. Example: 7
*
* @param string $groupId
......
......@@ -3,21 +3,24 @@
namespace Source\UseCases\GroupSchedule\GetGroupSchedules;
use Source\Entities\Schedule;
use Source\Sanitize\Paginates;
use Source\UseCases\BasePresenter;
class ApiPresenter extends BasePresenter implements Presenter
{
protected array $viewModel = [];
use Paginates;
protected array $schedules = [];
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->viewModel['schedules'] = array_map(fn (Schedule $schedule): array => self::formatSchedule($schedule), $responseModel->getSchedules());
$this->schedules = array_map(fn (Schedule $schedule): array => self::formatSchedule($schedule), $responseModel->getSchedules());
}
/** @inheritDoc */
public function getViewModel(): array
{
return $this->viewModel;
return $this->paginate($this->schedules);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment