Files
firefly-iii/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php
T

395 lines
17 KiB
PHP
Raw Normal View History

2018-04-13 17:28:11 +02:00
<?php
2021-03-28 11:39:26 +02:00
/*
* ListController.php
* Copyright (c) 2021 james@firefly-iii.org
*
* This file is part of Firefly III (https://github.com/firefly-iii).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2018-04-15 19:20:24 +02:00
2021-03-28 11:39:26 +02:00
declare(strict_types=1);
2021-03-06 21:39:29 +01:00
2021-03-28 11:39:26 +02:00
namespace FireflyIII\Api\V1\Controllers\Models\TransactionCurrency;
2018-04-13 17:28:11 +02:00
2021-03-06 21:39:29 +01:00
use FireflyIII\Api\V1\Controllers\Controller;
2019-03-25 15:14:09 +01:00
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
2018-12-08 21:26:20 +01:00
use FireflyIII\Models\Account;
use FireflyIII\Models\Bill;
use FireflyIII\Models\Recurrence;
use FireflyIII\Models\Rule;
2018-04-13 17:28:11 +02:00
use FireflyIII\Models\TransactionCurrency;
2018-12-08 21:26:20 +01:00
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
2019-08-30 08:02:11 +02:00
use FireflyIII\Repositories\Budget\AvailableBudgetRepositoryInterface;
2019-08-30 07:54:09 +02:00
use FireflyIII\Repositories\Budget\BudgetLimitRepositoryInterface;
2018-12-08 21:26:20 +01:00
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
use FireflyIII\Repositories\Rule\RuleRepositoryInterface;
use FireflyIII\Support\Http\Api\AccountFilter;
use FireflyIII\Support\Http\Api\TransactionFilter;
use FireflyIII\Support\JsonApi\Enrichments\AccountEnrichment;
2025-08-03 17:42:07 +02:00
use FireflyIII\Support\JsonApi\Enrichments\BudgetLimitEnrichment;
2025-08-07 05:59:26 +02:00
use FireflyIII\Support\JsonApi\Enrichments\RecurringEnrichment;
2025-07-31 10:00:05 +02:00
use FireflyIII\Support\JsonApi\Enrichments\SubscriptionEnrichment;
use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
2018-12-08 21:26:20 +01:00
use FireflyIII\Transformers\AccountTransformer;
use FireflyIII\Transformers\AvailableBudgetTransformer;
use FireflyIII\Transformers\BillTransformer;
use FireflyIII\Transformers\BudgetLimitTransformer;
use FireflyIII\Transformers\RecurrenceTransformer;
use FireflyIII\Transformers\RuleTransformer;
2019-03-25 15:14:09 +01:00
use FireflyIII\Transformers\TransactionGroupTransformer;
2018-07-05 06:10:35 +02:00
use FireflyIII\User;
2018-04-15 19:20:24 +02:00
use Illuminate\Http\JsonResponse;
2018-04-13 17:28:11 +02:00
use Illuminate\Http\Request;
2018-04-15 19:20:24 +02:00
use Illuminate\Pagination\LengthAwarePaginator;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
2018-04-13 17:28:11 +02:00
use League\Fractal\Resource\Collection as FractalCollection;
/**
2021-03-06 21:39:29 +01:00
* Class ListController
2018-04-13 17:28:11 +02:00
*/
2026-03-03 20:33:02 +01:00
final class ListController extends Controller
2018-04-13 17:28:11 +02:00
{
2022-10-30 14:23:00 +01:00
use AccountFilter;
use TransactionFilter;
2020-07-31 09:42:00 +02:00
2018-12-08 21:26:20 +01:00
/**
2021-09-19 10:20:28 +02:00
* This endpoint is documented at:
2023-02-12 06:53:36 +01:00
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/listAccountByCurrency
2018-12-08 21:26:20 +01:00
* Display a list of accounts.
*/
public function accounts(Request $request, TransactionCurrency $currency): JsonResponse
{
2026-01-23 15:14:29 +01:00
$manager = $this->getManager();
2018-12-08 21:26:20 +01:00
2022-04-12 18:19:30 +02:00
// read type from URL
2026-01-23 15:14:29 +01:00
$type = $request->get('type') ?? 'all';
2018-12-08 21:26:20 +01:00
$this->parameters->set('type', $type);
// types to get, page size:
2026-01-23 15:14:29 +01:00
$types = $this->mapAccountTypes($this->parameters->get('type'));
$pageSize = $this->parameters->get('limit');
2018-12-08 21:26:20 +01:00
// get list of accounts. Count it and split it.
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$unfiltered = $accountRepository->getAccountsByType($types);
// filter list on currency preference:
2026-01-23 15:14:29 +01:00
$collection = $unfiltered->filter(static function (Account $account) use ($currency, $accountRepository): bool {
2026-01-23 15:09:50 +01:00
$currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
2018-12-08 21:26:20 +01:00
2026-01-23 15:09:50 +01:00
return $currencyId === $currency->id;
});
2018-12-08 21:26:20 +01:00
2026-01-23 15:14:29 +01:00
$count = $collection->count();
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
2018-12-08 21:26:20 +01:00
2025-10-07 07:06:54 +02:00
// #11007 go to the end of the previous day.
2025-10-07 09:49:35 +02:00
$this->parameters->set('start', $this->parameters->get('start')?->subSecond());
2025-10-07 10:06:54 +02:00
// #11018 also end of the day.
2025-10-07 10:03:26 +02:00
$this->parameters->set('end', $this->parameters->get('end')?->endOfDay());
2025-10-07 07:06:54 +02:00
// enrich
/** @var User $admin */
2026-01-23 15:14:29 +01:00
$admin = auth()->user();
$enrichment = new AccountEnrichment();
2025-08-03 10:22:12 +02:00
$enrichment->setDate($this->parameters->get('date'));
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
$enrichment->setUser($admin);
2026-01-23 15:14:29 +01:00
$accounts = $enrichment->enrich($accounts);
2018-12-08 21:26:20 +01:00
// make paginator:
2026-01-23 15:14:29 +01:00
$paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]).$this->buildParams());
2018-12-08 21:26:20 +01:00
2018-12-15 22:03:05 +01:00
/** @var AccountTransformer $transformer */
2026-01-23 15:14:29 +01:00
$transformer = app(AccountTransformer::class);
2018-12-15 22:03:05 +01:00
$transformer->setParameters($this->parameters);
2026-01-23 15:14:29 +01:00
$resource = new FractalCollection($accounts, $transformer, 'accounts');
2018-12-08 21:26:20 +01:00
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
2020-10-03 16:51:44 +02:00
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
2018-12-08 21:26:20 +01:00
}
/**
2021-09-19 10:20:28 +02:00
* This endpoint is documented at:
2023-02-12 06:53:36 +01:00
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/listAvailableBudgetByCurrency
2021-09-19 10:20:28 +02:00
*
2018-12-10 21:45:44 +01:00
* Display a listing of the resource.
2018-12-08 21:26:20 +01:00
*/
2019-09-04 17:39:39 +02:00
public function availableBudgets(TransactionCurrency $currency): JsonResponse
2018-12-08 21:26:20 +01:00
{
2026-01-23 15:14:29 +01:00
$manager = $this->getManager();
2018-12-08 21:26:20 +01:00
// types to get, page size:
2026-01-23 15:14:29 +01:00
$pageSize = $this->parameters->get('limit');
2018-12-08 21:26:20 +01:00
// get list of available budgets. Count it and split it.
2019-08-30 08:02:11 +02:00
/** @var AvailableBudgetRepositoryInterface $abRepository */
2026-01-23 15:14:29 +01:00
$abRepository = app(AvailableBudgetRepositoryInterface::class);
2019-08-30 08:02:11 +02:00
$collection = $abRepository->getAvailableBudgetsByCurrency($currency);
2018-12-08 21:26:20 +01:00
$count = $collection->count();
$availableBudgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
2026-01-23 15:14:29 +01:00
$paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.available-budgets', [$currency->code]).$this->buildParams());
2018-12-08 21:26:20 +01:00
2018-12-15 22:03:05 +01:00
/** @var AvailableBudgetTransformer $transformer */
2026-01-23 15:14:29 +01:00
$transformer = app(AvailableBudgetTransformer::class);
2018-12-15 22:03:05 +01:00
$transformer->setParameters($this->parameters);
2026-01-23 15:14:29 +01:00
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
2018-12-08 21:26:20 +01:00
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
2020-10-03 16:51:44 +02:00
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
2018-12-08 21:26:20 +01:00
}
/**
2021-09-19 10:20:28 +02:00
* This endpoint is documented at:
2023-02-12 06:53:36 +01:00
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/listBillByCurrency
2021-09-19 10:20:28 +02:00
*
2018-12-08 21:26:20 +01:00
* List all bills
*/
2019-09-04 17:39:39 +02:00
public function bills(TransactionCurrency $currency): JsonResponse
2018-12-08 21:26:20 +01:00
{
2026-01-23 15:14:29 +01:00
$manager = $this->getManager();
2018-12-08 21:26:20 +01:00
2020-10-13 06:28:07 +02:00
/** @var BillRepositoryInterface $billRepos */
2026-01-23 15:14:29 +01:00
$billRepos = app(BillRepositoryInterface::class);
$pageSize = $this->parameters->get('limit');
$unfiltered = $billRepos->getBills();
2018-12-08 21:26:20 +01:00
// filter and paginate list:
2026-01-23 15:14:29 +01:00
$collection = $unfiltered->filter(static fn (Bill $bill): bool => $bill->transaction_currency_id === $currency->id);
$count = $collection->count();
$bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
2018-12-08 21:26:20 +01:00
2025-07-31 10:00:05 +02:00
// enrich
/** @var User $admin */
2026-01-23 15:14:29 +01:00
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
2025-07-31 10:00:05 +02:00
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
2026-01-23 15:14:29 +01:00
$bills = $enrichment->enrich($bills);
2025-07-31 10:00:05 +02:00
2018-12-08 21:26:20 +01:00
// make paginator:
2026-01-23 15:14:29 +01:00
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.bills', [$currency->code]).$this->buildParams());
2018-12-08 21:26:20 +01:00
2018-12-15 22:03:05 +01:00
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer->setParameters($this->parameters);
2026-01-23 15:14:29 +01:00
$resource = new FractalCollection($bills, $transformer, 'bills');
2018-12-08 21:26:20 +01:00
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
2020-10-03 16:51:44 +02:00
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
2018-12-08 21:26:20 +01:00
}
/**
2021-09-19 10:20:28 +02:00
* This endpoint is documented at:
2023-02-12 06:53:36 +01:00
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/listBudgetLimitByCurrency
2021-09-19 10:20:28 +02:00
*
2018-12-08 21:26:20 +01:00
* List all budget limits
*/
2019-09-04 17:39:39 +02:00
public function budgetLimits(TransactionCurrency $currency): JsonResponse
2018-12-08 21:26:20 +01:00
{
2019-08-30 07:54:09 +02:00
/** @var BudgetLimitRepositoryInterface $blRepository */
$blRepository = app(BudgetLimitRepositoryInterface::class);
2019-09-04 17:39:39 +02:00
$manager = $this->getManager();
2023-10-05 18:52:01 +02:00
$pageSize = $this->parameters->get('limit');
2019-08-30 07:54:09 +02:00
$collection = $blRepository->getAllBudgetLimitsByCurrency($currency, $this->parameters->get('start'), $this->parameters->get('end'));
2018-12-08 21:26:20 +01:00
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
2026-01-23 15:14:29 +01:00
$paginator->setPath(route('api.v1.currencies.budget-limits', [$currency->code]).$this->buildParams());
2018-12-08 21:26:20 +01:00
2025-08-03 17:42:07 +02:00
// enrich
/** @var User $admin */
2026-01-23 15:14:29 +01:00
$admin = auth()->user();
$enrichment = new BudgetLimitEnrichment();
2025-08-03 17:42:07 +02:00
$enrichment->setUser($admin);
2025-08-04 05:42:41 +02:00
$budgetLimits = $enrichment->enrich($budgetLimits);
2025-08-03 17:42:07 +02:00
2018-12-15 22:03:05 +01:00
/** @var BudgetLimitTransformer $transformer */
2026-01-23 15:14:29 +01:00
$transformer = app(BudgetLimitTransformer::class);
2018-12-15 22:03:05 +01:00
$transformer->setParameters($this->parameters);
2026-01-23 15:14:29 +01:00
$resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
2018-12-08 21:26:20 +01:00
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
2020-10-03 16:51:44 +02:00
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
2018-12-08 21:26:20 +01:00
}
/**
2021-09-19 10:20:28 +02:00
* This endpoint is documented at:
2023-02-12 06:53:36 +01:00
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/listRecurrenceByCurrency
2021-09-19 10:20:28 +02:00
*
2018-12-08 21:26:20 +01:00
* List all recurring transactions.
*/
2019-09-04 17:39:39 +02:00
public function recurrences(TransactionCurrency $currency): JsonResponse
2018-12-08 21:26:20 +01:00
{
2026-01-23 15:14:29 +01:00
$manager = $this->getManager();
2018-12-08 21:26:20 +01:00
// types to get, page size:
2026-01-23 15:14:29 +01:00
$pageSize = $this->parameters->get('limit');
2018-12-08 21:26:20 +01:00
// get list of budgets. Count it and split it.
2020-10-13 06:28:07 +02:00
/** @var RecurringRepositoryInterface $recurringRepos */
$recurringRepos = app(RecurringRepositoryInterface::class);
$unfiltered = $recurringRepos->get();
2018-12-08 21:26:20 +01:00
// filter selection
2026-03-06 07:39:12 +01:00
$collection = $unfiltered->filter(static function (Recurrence $recurrence) use ($currency): null|Recurrence {
2026-01-23 15:09:50 +01:00
if (array_any(
$recurrence->recurrenceTransactions,
2026-01-23 15:14:29 +01:00
static fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id
2026-01-23 15:09:50 +01:00
)) {
return $recurrence;
2018-12-08 21:26:20 +01:00
}
2026-01-23 15:09:50 +01:00
return null;
});
2026-01-23 15:14:29 +01:00
$count = $collection->count();
$recurrences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
2025-08-07 05:59:26 +02:00
// enrich
/** @var User $admin */
2026-01-23 15:14:29 +01:00
$admin = auth()->user();
$enrichment = new RecurringEnrichment();
2025-08-07 05:59:26 +02:00
$enrichment->setUser($admin);
2026-01-23 15:14:29 +01:00
$recurrences = $enrichment->enrich($recurrences);
2018-12-08 21:26:20 +01:00
// make paginator:
2026-01-23 15:14:29 +01:00
$paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]).$this->buildParams());
2018-12-08 21:26:20 +01:00
2018-12-15 22:03:05 +01:00
/** @var RecurrenceTransformer $transformer */
2026-01-23 15:14:29 +01:00
$transformer = app(RecurrenceTransformer::class);
2018-12-15 22:03:05 +01:00
$transformer->setParameters($this->parameters);
2026-01-23 15:14:29 +01:00
$resource = new FractalCollection($recurrences, $transformer, 'recurrences');
2018-12-08 21:26:20 +01:00
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
2020-10-03 16:51:44 +02:00
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
2018-12-08 21:26:20 +01:00
}
/**
2021-09-19 10:20:28 +02:00
* This endpoint is documented at:
2023-02-12 06:53:36 +01:00
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/listRuleByCurrency
2021-09-19 10:20:28 +02:00
*
2018-12-08 21:26:20 +01:00
* List all of them.
*/
2019-09-04 17:39:39 +02:00
public function rules(TransactionCurrency $currency): JsonResponse
2018-12-08 21:26:20 +01:00
{
2026-01-23 15:14:29 +01:00
$manager = $this->getManager();
$pageSize = $this->parameters->get('limit');
2018-12-08 21:26:20 +01:00
// get list of budgets. Count it and split it.
2020-10-13 06:28:07 +02:00
/** @var RuleRepositoryInterface $ruleRepos */
2026-01-23 15:14:29 +01:00
$ruleRepos = app(RuleRepositoryInterface::class);
$unfiltered = $ruleRepos->getAll();
2026-01-23 15:09:50 +01:00
2026-03-06 07:39:12 +01:00
$collection = $unfiltered->filter(static function (Rule $rule) use ($currency): null|Rule {
2026-01-23 15:09:50 +01:00
if (array_any(
$rule->ruleTriggers,
2026-01-23 15:14:29 +01:00
static fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value
2026-01-23 15:09:50 +01:00
)) {
return $rule;
2018-12-08 21:26:20 +01:00
}
2026-01-23 15:09:50 +01:00
return null;
});
2026-01-23 15:14:29 +01:00
$count = $collection->count();
$rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
2018-12-08 21:26:20 +01:00
// make paginator:
2026-01-23 15:14:29 +01:00
$paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
$paginator->setPath(route('api.v1.rules.index').$this->buildParams());
2018-12-08 21:26:20 +01:00
2018-12-15 22:03:05 +01:00
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);
2026-01-23 15:14:29 +01:00
$resource = new FractalCollection($rules, $transformer, 'rules');
2018-12-08 21:26:20 +01:00
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
2020-10-03 16:51:44 +02:00
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
2018-12-08 21:26:20 +01:00
}
2018-04-13 17:28:11 +02:00
2018-12-10 21:45:44 +01:00
/**
2021-09-19 10:20:28 +02:00
* This endpoint is documented at:
2023-02-12 06:53:36 +01:00
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/currencies/listTransactionByCurrency
2021-09-19 10:20:28 +02:00
*
2018-12-10 21:45:44 +01:00
* Show all transactions.
*/
public function transactions(Request $request, TransactionCurrency $currency): JsonResponse
{
2026-01-23 15:14:29 +01:00
$pageSize = $this->parameters->get('limit');
$type = $request->get('type') ?? 'default';
2018-12-10 21:45:44 +01:00
$this->parameters->set('type', $type);
2026-01-23 15:14:29 +01:00
$types = $this->mapTransactionTypes($this->parameters->get('type'));
$manager = $this->getManager();
2018-12-10 21:45:44 +01:00
/** @var User $admin */
2026-01-23 15:14:29 +01:00
$admin = auth()->user();
2019-03-25 15:14:09 +01:00
// use new group collector:
/** @var GroupCollectorInterface $collector */
2026-01-23 15:14:29 +01:00
$collector = app(GroupCollectorInterface::class);
2019-03-25 15:14:09 +01:00
$collector
->setUser($admin)
// filter on currency.
->setCurrency($currency)
// all info needed for the API:
->withAPIInformation()
// set page size:
->setLimit($pageSize)
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
2026-01-23 15:14:29 +01:00
->setTypes($types)
;
2023-10-05 18:52:01 +02:00
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
}
if (null !== $this->parameters->get('end')) {
$collector->setEnd($this->parameters->get('end'));
2018-12-10 21:45:44 +01:00
}
2026-01-23 15:14:29 +01:00
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]).$this->buildParams());
// enrich
2026-01-23 15:14:29 +01:00
$enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
2018-12-10 21:45:44 +01:00
2019-03-25 15:14:09 +01:00
/** @var TransactionGroupTransformer $transformer */
2026-01-23 15:14:29 +01:00
$transformer = app(TransactionGroupTransformer::class);
2018-12-15 22:03:05 +01:00
$transformer->setParameters($this->parameters);
2026-01-23 15:14:29 +01:00
$resource = new FractalCollection($transactions, $transformer, 'transactions');
2018-12-10 21:45:44 +01:00
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
2020-10-03 16:51:44 +02:00
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
2018-12-10 21:45:44 +01:00
}
2021-03-28 11:39:26 +02:00
}