Commit 134a9b6d authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Merge branch '78-add-pagination-for-index-routes' into 'master'

Resolve "Add pagination for index routes."

Closes #78, #8, #9, #57, and #77

See merge request !65
parents 3c57ee43 660bf888
Pipeline #10500 passed with stages
in 3 minutes and 41 seconds
......@@ -5,39 +5,10 @@ namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\Attempts\GetAttempts\GetAttemptsUseCase;
use Source\UseCases\Attempts\GetAttemptsForDoor\GetAttemptsForDoorUseCase;
use Source\UseCases\Attempts\GetAttempts\APIPresenter as GetAttemptsAPIPresenter;
use Source\UseCases\Attempts\GetAttemptCountForDoor\GetAttemptCountForDoorUseCase;
use Source\UseCases\Attempts\GetAttemptCountForDoor\APIPresenter as AttemptCountAPIPresenter;
use Source\UseCases\Attempts\GetAttemptsForDoor\APIPresenter as GetAttemptsForDoorAPIPresenter;
use Source\UseCases\Attempts\APIPresenter as GetAttemptsAPIPresenter;
class AttemptsController extends ApiController
{
/**
* @param \Source\UseCases\Attempts\GetAttemptCountForDoor\GetAttemptCountForDoorUseCase $count
* @param string $doorId
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Exception
*/
public function count(GetAttemptCountForDoorUseCase $count, string $doorId): JsonResponse
{
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
]);
$presenter = new AttemptCountAPIPresenter();
$count->count($doorId, $this->request->input('start'), $this->request->input('end'), $presenter);
return $this->respondWithData($presenter->getViewModel());
}
/**
* @param \Source\UseCases\Attempts\GetAttempts\GetAttemptsUseCase $attempts
* @return \Illuminate\Http\JsonResponse
......@@ -51,44 +22,24 @@ class AttemptsController extends ApiController
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
'start' => 'date',
'end' => 'date',
'door_id' => 'integer',
]);
$presenter = new GetAttemptsAPIPresenter();
$attempts->getBetweenDates($this->request->input('start'), $this->request->input('end'), $presenter);
return $this->respondWithData($presenter->getViewModel());
}
/**
* @param \Source\UseCases\Attempts\GetAttemptsForDoor\GetAttemptsForDoorUseCase $doorAttempts
* @param string $doorId
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Exception
*/
public function doorAttempts(GetAttemptsForDoorUseCase $doorAttempts, string $doorId): JsonResponse
{
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
]);
$presenter = new GetAttemptsForDoorAPIPresenter();
$doorAttempts->getAttemptsForDoorBetween(
$doorId,
$attempts->getBetweenDates(
$this->request->input('start'),
$this->request->input('end'),
$this->request->input('door_id'),
$presenter
);
return $this->respondWithData($presenter->getViewModel());
return $this->respondWithData($presenter->getViewModel([
'start' => $this->request->input('start'),
'end' => $this->request->input('end'),
'door_id' => $this->request->input('door_id'),
]));
}
}
......@@ -5,19 +5,19 @@ namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\Doors\GetDoor\GetDoorUseCase;
use Source\UseCases\Doors\GetDoors\GetDoorsUseCase;
use Source\UseCases\Doors\CreateDoor\CreateDoorUseCase;
use Source\UseCases\Doors\DeleteDoor\DeleteDoorUseCase;
use Source\UseCases\Doors\UpdateDoor\UpdateDoorUseCase;
use Source\UseCases\Doors\GetAllDoors\GetAllDoorsUseCase;
use Source\UseCases\DoorGroup\GetDoorGroups\GetDoorGroupsUseCase;
use Source\UseCases\DoorGroup\AddDoorToGroup\AddDoorToGroupUseCase;
use Source\UseCases\Doors\GenerateDoorToken\GenerateDoorTokenUseCase;
use Source\UseCases\Doors\GetDoor\APIPresenter as GetDoorAPIPresenter;
use Source\UseCases\Doors\GetDoors\APIPresenter as GetAllDoorsAPIPresenter;
use Source\UseCases\Doors\CreateDoor\APIPresenter as CreateDoorAPIPresenter;
use Source\UseCases\Doors\DeleteDoor\APIPresenter as DeleteDoorAPIPresenter;
use Source\UseCases\Doors\UpdateDoor\APIPresenter as UpdateDoorAPIPresenter;
use Source\UseCases\DoorGroup\RemoveDoorFromGroup\RemoveDoorFromGroupUseCase;
use Source\UseCases\Doors\GetAllDoors\APIPresenter as GetAllDoorsAPIPresenter;
use Source\UseCases\DoorGroup\GetDoorGroups\APIPresenter as GetDoorGroupsAPIPresenter;
use Source\UseCases\DoorGroup\AddDoorToGroup\APIPresenter as AddDoorToGroupAPIPresenter;
use Source\UseCases\DoorGroup\RemoveDoorFromGroup\APIPresenter as RemoveDoorFromGroupAPIPresenter;
......@@ -25,20 +25,27 @@ use Source\UseCases\DoorGroup\RemoveDoorFromGroup\APIPresenter as RemoveDoorFrom
class DoorsController extends ApiController
{
/**
* @param \Source\UseCases\Doors\GetAllDoors\GetAllDoorsUseCase $getDoors
* @param \Source\UseCases\Doors\GetDoors\GetDoorsUseCase $getDoors
* @return \Illuminate\Http\JsonResponse
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Illuminate\Validation\ValidationException
*/
public function index(GetAllDoorsUseCase $getDoors): JsonResponse
public function index(GetDoorsUseCase $getDoors): JsonResponse
{
$this->authorizer->protect(Permissions::MANAGE_DOORS);
$this->validate($this->request, [
'query' => 'string'
]);
$presenter = new GetAllDoorsAPIPresenter();
$getDoors->all($presenter);
$getDoors->query($this->request->input('query'), $presenter);
return $this->respondWithData($presenter->getViewModel());
return $this->respondWithData($presenter->getViewModel([
'query' => $this->request->input('query'),
]));
}
/**
......@@ -90,6 +97,7 @@ class DoorsController extends ApiController
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityExistsException
*/
public function update(UpdateDoorUseCase $updateDoor, string $doorId): JsonResponse
{
......
......@@ -5,126 +5,43 @@ namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\Entries\APIPresenter;
use Source\UseCases\Entries\GetEntriesForDoor\GetEntriesForDoorUseCase;
use Source\UseCases\Entries\GetEntriesForUser\GetEntriesForUserUseCase;
use Source\UseCases\Entries\GetEntriesForDateRange\GetEntriesForDateRangeUseCase;
use Source\UseCases\Entries\GetEntriesForDoorAndUser\GetEntriesForDoorAndUserUseCase;
use Source\UseCases\Entries\GetEntries\GetEntriesUseCase;
class EntriesController extends ApiController
{
/**
* @param \Source\UseCases\Entries\GetEntriesForDateRange\GetEntriesForDateRangeUseCase $entriesBetween
* @param \Source\UseCases\Entries\GetEntries\GetEntriesUseCase $userEntries
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Exception
*/
public function index(GetEntriesForDateRangeUseCase $entriesBetween): JsonResponse
public function index(GetEntriesUseCase $userEntries): JsonResponse
{
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
'start' => 'date',
'end' => 'date',
'door_id' => 'integer',
'user_id' => 'integer',
]);
$presenter = new APIPresenter();
$entriesBetween->getForRange($this->request->input('start'), $this->request->input('end'), $presenter);
return $this->respondWithData($presenter->getViewModel());
}
/**
* @param \Source\UseCases\Entries\GetEntriesForDoor\GetEntriesForDoorUseCase $doorEntries
* @param string $doorId
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function doorEntries(GetEntriesForDoorUseCase $doorEntries, string $doorId): JsonResponse
{
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
]);
$presenter = new APIPresenter();
$doorEntries->getEntriesForDoorBetween(
$doorId,
$this->request->input('start'),
$this->request->input('end'),
$presenter
);
return $this->respondWithData($presenter->getViewModel());
}
/**
* @param \Source\UseCases\Entries\GetEntriesForUser\GetEntriesForUserUseCase $userEntries
* @param string $userId
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function userEntries(GetEntriesForUserUseCase $userEntries, string $userId): JsonResponse
{
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
]);
$presenter = new APIPresenter();
$userEntries->getEntriesForUserBetween(
$userId,
$this->request->input('start'),
$this->request->input('end'),
$presenter
);
return $this->respondWithData($presenter->getViewModel());
}
/**
* @param \Source\UseCases\Entries\GetEntriesForDoorAndUser\GetEntriesForDoorAndUserUseCase $doorUserEntries
* @param string $doorId
* @param string $userId
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function doorUserEntries(
GetEntriesForDoorAndUserUseCase $doorUserEntries,
string $doorId,
string $userId
): JsonResponse {
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
]);
$presenter = new APIPresenter();
$doorUserEntries->getEntriesForDoorAndUserBetween(
$doorId,
$userId,
$userEntries->getEntries(
$this->request->input('user_id'),
$this->request->input('door_id'),
$this->request->input('start'),
$this->request->input('end'),
$presenter
);
return $this->respondWithData($presenter->getViewModel());
return $this->respondWithData($presenter->getViewModel([
'start' => $this->request->input('start'),
'end' => $this->request->input('end'),
'door_id' => $this->request->input('door_id'),
'user_id' => $this->request->input('user_id'),
]));
}
}
......@@ -6,14 +6,14 @@ use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\Exceptions\DeleteFailedException;
use Source\UseCases\Groups\GetGroup\GetGroupUseCase;
use Source\UseCases\Groups\GetGroups\GetGroupsUseCase;
use Source\UseCases\Groups\CreateGroup\CreateGroupUseCase;
use Source\UseCases\Groups\DeleteGroup\DeleteGroupUseCase;
use Source\UseCases\Groups\UpdateGroup\UpdateGroupUseCase;
use Source\UseCases\Groups\GetAllGroups\GetAllGroupsUseCase;
use Source\UseCases\DoorGroup\GetGroupDoors\GetGroupDoorsUseCase;
use Source\UseCases\GroupUser\GetGroupUsers\GetGroupUsersUseCase;
use Source\UseCases\Groups\GetGroup\APIPresenter as GetGroupAPIPresenter;
use Source\UseCases\Groups\GetAllGroups\APIPresenter as AllGroupsAPIPresenter;
use Source\UseCases\Groups\GetGroups\APIPresenter as AllGroupsAPIPresenter;
use Source\UseCases\Groups\CreateGroup\APIPresenter as CreateGroupAPIPresenter;
use Source\UseCases\Groups\DeleteGroup\APIPresenter as DeleteGroupAPIPresenter;
use Source\UseCases\Groups\UpdateGroup\APIPresenter as UpdateGroupAPIPresenter;
......@@ -69,20 +69,27 @@ class GroupsController extends ApiController
}
/**
* @param \Source\UseCases\Groups\GetAllGroups\GetAllGroupsUseCase $useCase
* @param \Source\UseCases\Groups\GetGroups\GetGroupsUseCase $useCase
* @return \Illuminate\Http\JsonResponse
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Illuminate\Validation\ValidationException
*/
public function index(GetAllGroupsUseCase $useCase): JsonResponse
public function index(GetGroupsUseCase $useCase): JsonResponse
{
$this->authorizer->protectOne([Permissions::MANAGE_GROUPS, Permissions::MANAGE_USERS]);
$this->validate($this->request, [
'query' => 'string',
]);
$presenter = new AllGroupsAPIPresenter();
$useCase->all($presenter);
$useCase->search($this->request->input('query'), $presenter);
return $this->respondWithData($presenter->getViewModel());
return $this->respondWithData($presenter->getViewModel([
'query' => $this->request->input('query'),
]));
}
/**
......
......@@ -9,15 +9,15 @@ use Illuminate\Contracts\Auth\Guard;
use Source\Authorization\Authorizer;
use Source\Exceptions\AuthenticationException;
use Source\UseCases\Users\GetUser\GetUserUseCase;
use Source\UseCases\Tokens\GetTokens\GetTokensUseCase;
use Source\UseCases\Users\UpdateUser\UpdateUserUseCase;
use Source\UseCases\GroupUser\GetUserGroups\GetUserGroupsUseCase;
use Source\UseCases\TokenUser\GetUserTokens\GetUserTokensUseCase;
use Source\UseCases\DoorUser\UserDoorAccess\UserDoorAccessUseCase;
use Source\UseCases\Users\GetUser\APIPresenter as GetUserAPIPresenter;
use Source\UseCases\Tokens\GetTokens\APIPresenter as GetTokensApiPresenter;
use Source\UseCases\Users\UpdateUser\APIPresenter as UpdateUserAPIPresenter;
use Source\UseCases\DoorUser\UserDoorAccess\MePresenter as DoorUserMePresenter;
use Source\UseCases\GroupUser\GetUserGroups\APIPresenter as GetUserGroupsAPIPresenter;
use Source\UseCases\TokenUser\GetUserTokens\APIPresenter as GetUserTokensAPIPresenter;
class MeController extends ApiController
{
......@@ -101,15 +101,14 @@ class MeController extends ApiController
}
/**
* @param \Source\UseCases\TokenUser\GetUserTokens\GetUserTokensUseCase $userTokens
* @param \Source\UseCases\Tokens\GetTokens\GetTokensUseCase $userTokens
* @return \Illuminate\Http\JsonResponse
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function tokens(GetUserTokensUseCase $userTokens): JsonResponse
public function tokens(GetTokensUseCase $userTokens): JsonResponse
{
$presenter = new GetUserTokensAPIPresenter();
$presenter = new GetTokensApiPresenter();
$userTokens->getTokensForUser($this->userId, $presenter);
$userTokens->filter($this->userId, null, $presenter);
return $this->respondWithData($presenter->getViewModel());
}
......
......@@ -9,10 +9,9 @@ use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\Overrides\ApiPresenter;
use Source\UseCases\Overrides\OverrideGet\OverrideGetUseCase;
use Source\UseCases\Overrides\OverridesGet\OverridesGetUseCase;
use Source\UseCases\Overrides\OverrideCreate\OverrideCreateUseCase;
use Source\UseCases\Overrides\OverrideUpdate\OverrideUpdateUseCase;
use Source\UseCases\Overrides\OverridesForDoor\OverridesForDoorUseCase;
use Source\UseCases\Overrides\OverridesForDateRange\OverridesForDateRangeUseCase;
use Source\UseCases\Overrides\OverrideCreate\ApiPresenter as OverrideCreateApiPresenter;
class OverridesController extends ApiController
......@@ -94,48 +93,39 @@ class OverridesController extends ApiController
}
/**
* @param string $doorId
* @param \Source\UseCases\Overrides\OverridesForDoor\OverridesForDoorUseCase $overridesForDoor
* @return \Illuminate\Http\JsonResponse
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function forDoor(string $doorId, OverridesForDoorUseCase $overridesForDoor): JsonResponse
{
$this->authorizer->protect(Permissions::LOGS_READ);
$presenter = new ApiPresenter();
$overridesForDoor->getOverridesForDoor($doorId, $presenter);
return $this->respondWithData($presenter->getViewModel());
}
/**
* @param \Source\UseCases\Overrides\OverridesForDateRange\OverridesForDateRangeUseCase $overridesInDateRange
* @param \Source\UseCases\Overrides\OverridesGet\OverridesGetUseCase $overridesInDateRange
* @return \Illuminate\Http\JsonResponse
* @throws \Illuminate\Validation\ValidationException
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
* @throws \Exception
*/
public function index(OverridesForDateRangeUseCase $overridesInDateRange): JsonResponse
public function index(OverridesGetUseCase $overridesInDateRange): JsonResponse
{
$this->authorizer->protect(Permissions::LOGS_READ);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
'start' => 'date',
'end' => 'date',
'door_id' => 'integer',
'user_id' => 'integer',
]);
$presenter = new ApiPresenter();
$overridesInDateRange->getOverridesForDateRange(
$overridesInDateRange->filter(
$this->request->input('door_id'),
$this->request->input('user_id'),
$this->request->input('start'),
$this->request->input('end'),
$presenter
);
return $this->respondWithData($presenter->getViewModel());
return $this->respondWithData($presenter->getViewModel([
'start' => $this->request->input('start'),
'end' => $this->request->input('end'),
'door_id' => $this->request->input('door_id'),
'user_id' => $this->request->input('user_id'),
]));
}
}
......@@ -9,7 +9,6 @@ use Source\UseCases\Schedules\SchedulesGet\SchedulesGetUseCase;
use Source\UseCases\Schedules\APIPresenter as ScheduleApiPresenter;
use Source\UseCases\Schedules\ScheduleCreate\ScheduleCreateUseCase;
use Source\UseCases\Schedules\ScheduleUpdate\ScheduleUpdateUseCase;
use Source\UseCases\GroupSchedule\SchedulesForGroup\SchedulesForGroupUseCase;
use Source\UseCases\GroupSchedule\APIPresenter as SchedulesForGroupApiPresenter;
use Source\UseCases\Schedules\SchedulesGet\APIPresenter as SchedulesGetApiPresenter;
use Source\UseCases\GroupSchedule\ActiveSchedulesForGroup\ActiveSchedulesForGroupUseCase;
......@@ -70,24 +69,33 @@ class SchedulesController extends ApiController
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function between(SchedulesGetUseCase $schedulesBetween): JsonResponse
public function index(SchedulesGetUseCase $schedulesBetween): JsonResponse
{
$this->authorizer->protect(Permissions::MANAGE_DOORS);
$this->validate($this->request, [
'start' => 'required|date|before:end',
'end' => 'required|date|after:start',
'start' => 'date',
'end' => 'date',
'type' => 'integer',
'group_id' => 'integer',
]);
$presenter = new SchedulesGetApiPresenter();
$schedulesBetween->getBetweenDates(
$schedulesBetween->filter(
$this->request->input('group_id'),
$this->request->input('type'),
$this->request->input('start'),
$this->request->input('end'),
$presenter
);
return $this->respondWithData($presenter->getViewModel());
return $this->respondWithData($presenter->getViewModel([
'group_id' => $this->request->input('group_id'),
'type' => $this->request->input('type'),
'start' => $this->request->input('start'),
'end' => $this->request->input('end'),
]));
}
/**
......@@ -119,24 +127,6 @@ class SchedulesController extends ApiController
return $this->respondWithData($presenter->getViewModel());
}
/**
* @param string $groupId
* @param \Source\UseCases\GroupSchedule\SchedulesForGroup\SchedulesForGroupUseCase $forGroup
* @return \Illuminate\Http\JsonResponse
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function getForGroup(string $groupId, SchedulesForGroupUseCase $forGroup): JsonResponse
{
$this->authorizer->protect(Permissions::MANAGE_DOORS);
$presenter = new SchedulesForGroupApiPresenter();
$forGroup->getForGroup($groupId, $presenter);
return $this->respondWithData($presenter->getViewModel());
}
/**
* @param string $groupId
* @param \Source\UseCases\GroupSchedule\ActiveSchedulesForGroup\ActiveSchedulesForGroupUseCase $activeForGroup
......
......@@ -5,12 +5,12 @@ namespace App\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\Tokens\GetToken\GetTokenUseCase;
use Source\UseCases\Tokens\GetTokens\GetTokensUseCase;
use Source\UseCases\Tokens\CreateToken\CreateTokenUseCase;
use Source\UseCases\Tokens\ExpireToken\ExpireTokenUseCase;
use Source\UseCases\Tokens\UpdateToken\UpdateTokenUseCase;
use Source\UseCases\Tokens\GetAllTokens\GetAllTokensUseCase;
use Source\UseCases\Tokens\GetToken\APIPresenter as GetTokenAPIPresenter;
use Source\UseCases\Tokens\GetAllTokens\APIPresenter as AllTokensAPIPresenter;
use Source\UseCases\Tokens\GetTokens\APIPresenter as AllTokensAPIPresenter;
use Source\UseCases\Tokens\CreateToken\APIPresenter as CreateTokenAPIPresenter;
use Source\UseCases\Tokens\ExpireToken\APIPresenter as ExpireTokenAPIPresenter;
use Source\UseCases\Tokens\UpdateToken\APIPresenter as UpdateTokenAPIPresenter;
......@@ -18,20 +18,32 @@ use Source\UseCases\Tokens\UpdateToken\APIPresenter as UpdateTokenAPIPresenter;
class TokensController extends ApiController
{
/**
* @param \Source\UseCases\Tokens\GetAllTokens\GetAllTokensUseCase $allTokens
* @param \Source\UseCases\Tokens\GetTokens\GetTokensUseCase $allTokens
* @return \Illuminate\Http\JsonResponse
* @throws \Source\Exceptions\AuthorizationException
* @throws \Source\Exceptions\EntityNotFoundException
*/
public function index(GetAllTokensUseCase $allTokens): JsonResponse
public function index(GetTokensUseCase $allTokens): JsonResponse
{
$this->authorizer->protect(Permissions::MANAGE_USERS);
$this->validate($this->request, [
'user_id' => 'integer',
'valid_at' => 'date',
]);
$presenter = new AllTokensAPIPresenter();
$allTokens->all($presenter);
$allTokens->filter(
$this->request->input('user_id'),
$this->request->input('valid_at'),
$presenter
);
return $this->respondWithData($presenter->getViewModel());
return $this->respondWithData($presenter->getViewModel([
'user_id' => $this->request->input('user_id'),
'valid_at' => $this->request->input('valid_at'),
]));
}
/**
......
......@@ -7,43 +7,48 @@ use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;