Fix methods and clean up code.

This commit is contained in:
James Cole
2024-03-09 19:46:16 +01:00
parent 487b65b669
commit 66b322e844
19 changed files with 153 additions and 139 deletions

View File

@@ -158,7 +158,7 @@ class Controller extends BaseController
// the transformer, at this point, needs to collect information that ALL items in the collection
// require, like meta-data and stuff like that, and save it for later.
$objects = $transformer->collectMetaData($objects);
$objects = $transformer->collectMetaData($objects);
$paginator->setCollection($objects);
$resource = new FractalCollection($objects, $transformer, $key);

View File

@@ -47,7 +47,7 @@ class IndexController extends Controller
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
// new way of user group validation
$userGroup = $this->validateUserGroup($request);
$userGroup = $this->validateUserGroup($request);
if (null !== $userGroup) {
$this->repository->setUserGroup($userGroup);
}
@@ -62,7 +62,6 @@ class IndexController extends Controller
*/
public function index(IndexRequest $request): JsonResponse
{
$this->repository->resetAccountOrder();
$types = $request->getAccountTypes();
$instructions = $request->getSortInstructions('accounts');
@@ -78,7 +77,8 @@ class IndexController extends Controller
return response()
->json($this->jsonApiList('accounts', $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE);
->header('Content-Type', self::CONTENT_TYPE)
;
}
public function infiniteList(InfiniteListRequest $request): JsonResponse
@@ -86,7 +86,7 @@ class IndexController extends Controller
$this->repository->resetAccountOrder();
// get accounts of the specified type, and return.
$types = $request->getAccountTypes();
$types = $request->getAccountTypes();
// get from repository
$accounts = $this->repository->getAccountsInOrder($types, $request->getSortInstructions('accounts'), $request->getStartRow(), $request->getEndRow());
@@ -98,6 +98,7 @@ class IndexController extends Controller
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE);
->header('Content-Type', self::CONTENT_TYPE)
;
}
}