diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.php index cb0097062e..ab0e510911 100644 --- a/app/Api/V1/Controllers/Models/Account/ShowController.php +++ b/app/Api/V1/Controllers/Models/Account/ShowController.php @@ -70,48 +70,48 @@ class ShowController extends Controller */ public function index(ShowRequest $request): JsonResponse { - $manager = $this->getManager(); + $manager = $this->getManager(); [ - 'types' => $types, - 'page' => $page, - 'limit' => $limit, + 'types' => $types, + 'page' => $page, + 'limit' => $limit, 'offset' => $offset, - 'sort' => $sort, - 'start' => $start, - 'end' => $end, - 'date' => $date, - ] = $request->attributes->all(); + 'sort' => $sort, + 'start' => $start, + 'end' => $end, + 'date' => $date, + ] + = $request->attributes->all(); // get list of accounts. Count it and split it. $this->repository->resetAccountOrder(); - $collection = $this->repository->getAccountsByType($types, $sort); - $count = $collection->count(); + $collection = $this->repository->getAccountsByType($types, $sort); + $count = $collection->count(); // continue sort: // TODO if the user sorts on DB dependent field there must be no slice before enrichment, only after. // TODO still need to figure out how to do this easily. - $accounts = $collection->slice($offset, $limit); + $accounts = $collection->slice($offset, $limit); // enrich /** @var User $admin */ - $admin = auth()->user(); - $enrichment = new AccountEnrichment(); + $admin = auth()->user(); + $enrichment = new AccountEnrichment(); $enrichment->setSort($sort); $enrichment->setDate($date); $enrichment->setStart($start); $enrichment->setEnd($end); $enrichment->setUser($admin); - $accounts = $enrichment->enrich($accounts); + $accounts = $enrichment->enrich($accounts); // make paginator: - $paginator = new LengthAwarePaginator($accounts, $count, $limit, $page); - $paginator->setPath(route('api.v1.accounts.index').$this->buildParams()); + $paginator = new LengthAwarePaginator($accounts, $count, $limit, $page); + $paginator->setPath(route('api.v1.accounts.index') . $this->buildParams()); /** @var AccountTransformer $transformer */ $transformer = app(AccountTransformer::class); - $transformer->setParameters($this->parameters); - $resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY); + $resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); @@ -128,27 +128,22 @@ class ShowController extends Controller // get list of accounts. Count it and split it. $this->repository->resetAccountOrder(); $account->refresh(); - $manager = $this->getManager(); - [ - 'start' => $start, - 'end' => $end, - 'date' => $date, - ] = $request->attributes->all(); + $manager = $this->getManager(); + [$start, $end, $date,] = $request->attributes->all(); // enrich /** @var User $admin */ - $admin = auth()->user(); - $enrichment = new AccountEnrichment(); + $admin = auth()->user(); + $enrichment = new AccountEnrichment(); $enrichment->setDate($date); $enrichment->setStart($start); $enrichment->setEnd($end); $enrichment->setUser($admin); - $account = $enrichment->enrichSingle($account); + $account = $enrichment->enrichSingle($account); /** @var AccountTransformer $transformer */ $transformer = app(AccountTransformer::class); - $transformer->setParameters($this->parameters); $resource = new Item($account, $transformer, self::RESOURCE_KEY); return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE); diff --git a/app/Api/V1/Controllers/Models/UserGroup/IndexController.php b/app/Api/V1/Controllers/Models/UserGroup/IndexController.php index 8c4ba0ddbb..cda1faa21a 100644 --- a/app/Api/V1/Controllers/Models/UserGroup/IndexController.php +++ b/app/Api/V1/Controllers/Models/UserGroup/IndexController.php @@ -65,8 +65,6 @@ class IndexController extends Controller $paginator = new LengthAwarePaginator($administrations, $count, $limit, $page); $transformer = new UserGroupTransformer(); - $transformer->setParameters($request->attributes); // give params to transformer - return response() ->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer)) ->header('Content-Type', self::CONTENT_TYPE) diff --git a/app/Api/V1/Requests/AggregateFormRequest.php b/app/Api/V1/Requests/AggregateFormRequest.php index 207ce0640d..9e9fbf7e92 100644 --- a/app/Api/V1/Requests/AggregateFormRequest.php +++ b/app/Api/V1/Requests/AggregateFormRequest.php @@ -1,7 +1,7 @@ 'date|after:1970-01-02|before:2038-01-17|before:end|required_with:end|' . $this->required, - 'end' => 'date|after:1970-01-02|before:2038-01-17|after:start|required_with:start|' . $this->required, + 'start' => sprintf('date|after:1970-01-02|before:2038-01-17|before:end|required_with:end|' , $this->required), + 'end' => sprintf('date|after:1970-01-02|before:2038-01-17|after:start|required_with:start|' , $this->required), ]; } diff --git a/app/Api/V1/Requests/DateRequest.php b/app/Api/V1/Requests/DateRequest.php index c59dd65b13..5a87fb3086 100644 --- a/app/Api/V1/Requests/DateRequest.php +++ b/app/Api/V1/Requests/DateRequest.php @@ -1,7 +1,7 @@ parameters; } + /** + * @deprecated + */ final public function setParameters(ParameterBag $parameters): void { $this->parameters = $parameters; diff --git a/app/Transformers/AccountTransformer.php b/app/Transformers/AccountTransformer.php index c9e5d3aeee..5538e745e7 100644 --- a/app/Transformers/AccountTransformer.php +++ b/app/Transformers/AccountTransformer.php @@ -30,7 +30,6 @@ use FireflyIII\Models\Account; use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; use FireflyIII\Support\Facades\Amount; -use Symfony\Component\HttpFoundation\ParameterBag; /** * Class AccountTransformer @@ -46,7 +45,6 @@ class AccountTransformer extends AbstractTransformer */ public function __construct() { - $this->parameters = new ParameterBag(); $this->repository = app(AccountRepositoryInterface::class); $this->convertToPrimary = Amount::convertToPrimary(); $this->primary = Amount::getPrimaryCurrency();