Merge branch 'develop' into main

This commit is contained in:
mergify[bot]
2026-02-01 12:11:25 +00:00
committed by GitHub
1095 changed files with 21424 additions and 20575 deletions
+32 -32
View File
@@ -402,16 +402,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v3.92.5",
"version": "v3.93.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "260cc8c4a1d2f6d2f22cd4f9c70aa72e55ebac58"
"reference": "50895a07cface1385082e4caa6a6786c4e033468"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/260cc8c4a1d2f6d2f22cd4f9c70aa72e55ebac58",
"reference": "260cc8c4a1d2f6d2f22cd4f9c70aa72e55ebac58",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/50895a07cface1385082e4caa6a6786c4e033468",
"reference": "50895a07cface1385082e4caa6a6786c4e033468",
"shasum": ""
},
"require": {
@@ -443,14 +443,14 @@
},
"require-dev": {
"facile-it/paraunit": "^1.3.1 || ^2.7",
"infection/infection": "^0.31",
"infection/infection": "^0.32",
"justinrainbow/json-schema": "^6.6",
"keradus/cli-executor": "^2.3",
"mikey179/vfsstream": "^1.6.12",
"php-coveralls/php-coveralls": "^2.9",
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.6",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.6",
"phpunit/phpunit": "^9.6.31 || ^10.5.60 || ^11.5.46",
"phpunit/phpunit": "^9.6.31 || ^10.5.60 || ^11.5.48",
"symfony/polyfill-php85": "^1.33",
"symfony/var-dumper": "^5.4.48 || ^6.4.26 || ^7.4.0 || ^8.0",
"symfony/yaml": "^5.4.45 || ^6.4.30 || ^7.4.1 || ^8.0"
@@ -494,7 +494,7 @@
],
"support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.92.5"
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.93.0"
},
"funding": [
{
@@ -502,7 +502,7 @@
"type": "github"
}
],
"time": "2026-01-08T21:57:37+00:00"
"time": "2026-01-23T17:33:21+00:00"
},
{
"name": "psr/container",
@@ -1252,16 +1252,16 @@
},
{
"name": "symfony/console",
"version": "v8.0.3",
"version": "v8.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "6145b304a5c1ea0bdbd0b04d297a5864f9a7d587"
"reference": "ace03c4cf9805080ff40cbeec69fca180c339a3b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/6145b304a5c1ea0bdbd0b04d297a5864f9a7d587",
"reference": "6145b304a5c1ea0bdbd0b04d297a5864f9a7d587",
"url": "https://api.github.com/repos/symfony/console/zipball/ace03c4cf9805080ff40cbeec69fca180c339a3b",
"reference": "ace03c4cf9805080ff40cbeec69fca180c339a3b",
"shasum": ""
},
"require": {
@@ -1318,7 +1318,7 @@
"terminal"
],
"support": {
"source": "https://github.com/symfony/console/tree/v8.0.3"
"source": "https://github.com/symfony/console/tree/v8.0.4"
},
"funding": [
{
@@ -1338,7 +1338,7 @@
"type": "tidelift"
}
],
"time": "2025-12-23T14:52:06+00:00"
"time": "2026-01-13T13:06:50+00:00"
},
{
"name": "symfony/deprecation-contracts",
@@ -1409,16 +1409,16 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v8.0.0",
"version": "v8.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "573f95783a2ec6e38752979db139f09fec033f03"
"reference": "99301401da182b6cfaa4700dbe9987bb75474b47"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/573f95783a2ec6e38752979db139f09fec033f03",
"reference": "573f95783a2ec6e38752979db139f09fec033f03",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/99301401da182b6cfaa4700dbe9987bb75474b47",
"reference": "99301401da182b6cfaa4700dbe9987bb75474b47",
"shasum": ""
},
"require": {
@@ -1470,7 +1470,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/event-dispatcher/tree/v8.0.0"
"source": "https://github.com/symfony/event-dispatcher/tree/v8.0.4"
},
"funding": [
{
@@ -1490,7 +1490,7 @@
"type": "tidelift"
}
],
"time": "2025-10-30T14:17:19+00:00"
"time": "2026-01-05T11:45:55+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
@@ -1640,16 +1640,16 @@
},
{
"name": "symfony/finder",
"version": "v8.0.3",
"version": "v8.0.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "dd3a2953570a283a2ba4e17063bb98c734cf5b12"
"reference": "8bd576e97c67d45941365bf824e18dc8538e6eb0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/dd3a2953570a283a2ba4e17063bb98c734cf5b12",
"reference": "dd3a2953570a283a2ba4e17063bb98c734cf5b12",
"url": "https://api.github.com/repos/symfony/finder/zipball/8bd576e97c67d45941365bf824e18dc8538e6eb0",
"reference": "8bd576e97c67d45941365bf824e18dc8538e6eb0",
"shasum": ""
},
"require": {
@@ -1684,7 +1684,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v8.0.3"
"source": "https://github.com/symfony/finder/tree/v8.0.5"
},
"funding": [
{
@@ -1704,7 +1704,7 @@
"type": "tidelift"
}
],
"time": "2025-12-23T14:52:06+00:00"
"time": "2026-01-26T15:08:38+00:00"
},
{
"name": "symfony/options-resolver",
@@ -2576,16 +2576,16 @@
},
{
"name": "symfony/string",
"version": "v8.0.1",
"version": "v8.0.4",
"source": {
"type": "git",
"url": "https://github.com/symfony/string.git",
"reference": "ba65a969ac918ce0cc3edfac6cdde847eba231dc"
"reference": "758b372d6882506821ed666032e43020c4f57194"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/string/zipball/ba65a969ac918ce0cc3edfac6cdde847eba231dc",
"reference": "ba65a969ac918ce0cc3edfac6cdde847eba231dc",
"url": "https://api.github.com/repos/symfony/string/zipball/758b372d6882506821ed666032e43020c4f57194",
"reference": "758b372d6882506821ed666032e43020c4f57194",
"shasum": ""
},
"require": {
@@ -2642,7 +2642,7 @@
"utf8"
],
"support": {
"source": "https://github.com/symfony/string/tree/v8.0.1"
"source": "https://github.com/symfony/string/tree/v8.0.4"
},
"funding": [
{
@@ -2662,7 +2662,7 @@
"type": "tidelift"
}
],
"time": "2025-12-01T09:13:36+00:00"
"time": "2026-01-12T12:37:40+00:00"
}
],
"packages-dev": [],
+9 -1
View File
@@ -14,7 +14,15 @@ SITE_OWNER=mail@example.com
# Change it to a string of exactly 32 chars or use something like `php artisan key:generate` to generate it.
# If you use Docker or similar, you can set this variable from a file by using APP_KEY_FILE
#
# Avoid the "#" character in your APP_KEY, it may break things.
# Try to avoid special characters like #, < and > in your app key. This string does not need full entropy
# When in doubt, follow the link below and pick one.
#
# https://www.random.org/strings/?num=5&len=32&digits=on&upperalpha=on&loweralpha=on&unique=on&format=html&rnd=new
#
# If you are a fancy linux nerd like me, use this command:
#
# head /dev/urandom | LC_ALL=C tr -dc 'A-Za-z0-9' | head -c 32 && echo
#
#
APP_KEY=SomeRandomStringOf32CharsExactly
+3
View File
@@ -4,6 +4,9 @@ Over time, many people have contributed to Firefly III. Their efforts are not al
Please find below all the people who contributed to the Firefly III code. Their names are mentioned in the year of their first contribution.
## 2026
- Nick Huang
- mateuszkulapl
- Gianluca Martino
- embedded
## 2025
@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Data\Bulk;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Data\Bulk\TransactionRequest;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Services\Internal\Destroy\AccountDestroyService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
/**
* Class TransactionController
@@ -51,16 +51,14 @@ class TransactionController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->validateUserGroup($request);
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUserGroup($this->userGroup);
$this->repository->setUser($this->user);
$this->middleware(function (Request $request, $next) {
$this->validateUserGroup($request);
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUserGroup($this->userGroup);
$this->repository->setUser($this->user);
return $next($request);
}
);
return $next($request);
});
}
public function update(TransactionRequest $request): JsonResponse
@@ -24,12 +24,12 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Data\Export;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Data\Export\ExportRequest;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Support\Export\ExportDataGenerator;
use Illuminate\Http\Request;
use Illuminate\Http\Response as LaravelResponse;
use Safe\Exceptions\DatetimeException;
@@ -49,16 +49,14 @@ class ExportController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->validateUserGroup($request);
$this->exporter = app(ExportDataGenerator::class);
$this->exporter->setUserGroup($this->userGroup);
$this->exporter->setUser($this->user);
$this->middleware(function (Request $request, $next) {
$this->validateUserGroup($request);
$this->exporter = app(ExportDataGenerator::class);
$this->exporter->setUserGroup($this->userGroup);
$this->exporter->setUser($this->user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -42,7 +42,7 @@ class AccountController extends Controller
use ApiSupport;
private OperationsRepositoryInterface $opsRepository;
private AccountRepositoryInterface $repository;
private AccountRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -50,18 +50,16 @@ class AccountController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function asset(GenericRequest $request): JsonResponse
@@ -46,15 +46,13 @@ class BillController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -97,7 +95,14 @@ class BillController extends Controller
if ($convertToPrimary && $journal['currency_id'] !== $primary->id && $primary->id === $journal['foreign_currency_id']) {
$field = 'foreign_amount';
}
Log::debug(sprintf('Journal #%d in bill #%d will use %s (%s %s)', $journal['transaction_group_id'], $billId, $field, $currencyCode, $journal[$field] ?? '0'));
Log::debug(sprintf(
'Journal #%d in bill #%d will use %s (%s %s)',
$journal['transaction_group_id'],
$billId,
$field,
$currencyCode,
$journal[$field] ?? '0'
));
$key = sprintf('%d-%d', $billId, $currencyId);
@@ -38,9 +38,9 @@ use Illuminate\Support\Collection;
*/
class BudgetController extends Controller
{
private NoBudgetRepositoryInterface $noRepository;
private NoBudgetRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
private BudgetRepositoryInterface $repository;
private BudgetRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -48,19 +48,17 @@ class BudgetController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(BudgetRepositoryInterface::class);
$this->noRepository = app(NoBudgetRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
$this->middleware(function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(BudgetRepositoryInterface::class);
$this->noRepository = app(NoBudgetRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function budget(GenericRequest $request): JsonResponse
@@ -40,7 +40,7 @@ class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
private CategoryRepositoryInterface $repository;
private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -48,19 +48,17 @@ class CategoryController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
$this->middleware(function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function category(GenericRequest $request): JsonResponse
@@ -73,7 +73,6 @@ class PeriodController extends Controller
$amount = $journal['amount'];
}
$response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
@@ -46,14 +46,12 @@ class TagController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -42,7 +42,7 @@ class AccountController extends Controller
use ApiSupport;
private OperationsRepositoryInterface $opsRepository;
private AccountRepositoryInterface $repository;
private AccountRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -50,18 +50,16 @@ class AccountController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function asset(GenericRequest $request): JsonResponse
@@ -40,7 +40,7 @@ class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
private CategoryRepositoryInterface $repository;
private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -48,19 +48,17 @@ class CategoryController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
$this->middleware(function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function category(GenericRequest $request): JsonResponse
@@ -46,15 +46,13 @@ class TagController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -100,7 +98,6 @@ class TagController extends Controller
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
return response()->json(array_values($response));
@@ -161,7 +158,10 @@ class TagController extends Controller
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignKey]['difference'] = bcadd((string) $response[$foreignKey]['difference'], Steam::positive($journal['foreign_amount']));
$response[$foreignKey]['difference'] = bcadd(
(string) $response[$foreignKey]['difference'],
Steam::positive($journal['foreign_amount'])
);
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
}
}
@@ -45,15 +45,13 @@ class AccountController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->opsRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function asset(GenericRequest $request): JsonResponse
@@ -40,7 +40,7 @@ class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
private CategoryRepositoryInterface $repository;
private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -48,19 +48,17 @@ class CategoryController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
$this->middleware(function ($request, $next) {
$this->opsRepository = app(OperationsRepositoryInterface::class);
$this->repository = app(CategoryRepositoryInterface::class);
$this->noRepository = app(NoCategoryRepositoryInterface::class);
$user = auth()->user();
$this->opsRepository->setUser($user);
$this->repository->setUser($user);
$this->noRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function category(GenericRequest $request): JsonResponse
@@ -74,7 +74,6 @@ class PeriodController extends Controller
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
return response()->json(array_values($response));
@@ -46,15 +46,13 @@ class TagController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
public function noTag(GenericRequest $request): JsonResponse
@@ -66,7 +64,6 @@ class TagController extends Controller
$convertToPrimary = Amount::convertToPrimary();
$primary = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts.
$collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);
@@ -98,7 +95,6 @@ class TagController extends Controller
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
return response()->json(array_values($response));
@@ -45,14 +45,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -60,37 +60,31 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
public function attachments(PaginationRequest $request, Account $account): JsonResponse
{
$manager = $this->getManager();
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
$collection = $this->repository->getAttachments($account);
$manager = $this->getManager();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
$collection = $this->repository->getAttachments($account);
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator->setPath(route('api.v1.accounts.attachments', [$account->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer = app(AttachmentTransformer::class);
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -99,35 +93,31 @@ class ListController extends Controller
public function piggyBanks(PaginationRequest $request, Account $account): JsonResponse
{
// create some objects:
$manager = $this->getManager();
$manager = $this->getManager();
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
// get list of piggy banks. Count it and split it.
$collection = $this->repository->getPiggyBanks($account);
$count = $collection->count();
$piggyBanks = $collection->slice($offset, $limit);
$collection = $this->repository->getPiggyBanks($account);
$count = $collection->count();
$piggyBanks = $collection->slice($offset, $limit);
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new PiggyBankEnrichment();
$admin = auth()->user();
$enrichment = new PiggyBankEnrichment();
$enrichment->setUser($admin);
$piggyBanks = $enrichment->enrich($piggyBanks);
$piggyBanks = $enrichment->enrich($piggyBanks);
// make paginator:
$paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);
$paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);
$paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]).$this->buildParams());
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer = app(PiggyBankTransformer::class);
// $transformer->setParameters($this->parameters);
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
$resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -138,21 +128,15 @@ class ListController extends Controller
*/
public function transactions(PaginationDateRangeRequest $request, Account $account): JsonResponse
{
[
'limit' => $limit,
'page' => $page,
'start' => $start,
'end' => $end,
'types' => $types,
] = $request->attributes->all();
$manager = $this->getManager();
['limit' => $limit, 'page' => $page, 'start' => $start, 'end' => $end, 'types' => $types] = $request->attributes->all();
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
$admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector = app(GroupCollectorInterface::class);
$collector->setUser($admin)->setAccounts(new Collection()->push($account))->withAPIInformation()->setLimit($limit)->setPage($page)->setTypes($types);
if (null !== $start) {
$collector->setStart($start);
@@ -161,18 +145,18 @@ class ListController extends Controller
$collector->setEnd($end);
}
$paginator = $collector->getPaginatedGroups();
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.accounts.transactions', [$account->id]).$this->buildParams());
// enrich
$enrichment = new TransactionGroupEnrichment();
$enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer = app(TransactionGroupTransformer::class);
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -55,14 +55,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -80,8 +78,7 @@ class ShowController extends Controller
'start' => $start,
'end' => $end,
'date' => $date,
]
= $request->attributes->all();
] = $request->attributes->all();
// get list of accounts. Count it and split it.
$this->repository->resetAccountOrder();
$collection = $this->repository->getAccountsByType($types, $sort);
@@ -127,25 +124,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' => $start, 'end' => $end, 'date' => $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);
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
$transformer = app(AccountTransformer::class);
$resource = new Item($account, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -48,14 +48,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -51,14 +51,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -48,16 +48,14 @@ class DestroyController extends Controller
{
parent::__construct();
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -55,16 +55,14 @@ class ShowController extends Controller
{
parent::__construct();
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -123,11 +121,7 @@ class ShowController extends Controller
*/
public function index(PaginationRequest $request): JsonResponse
{
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
if (true === auth()->user()->hasRole('demo')) {
Log::channel('audit')->warning(sprintf('Demo user tries to access attachment API in %s', __METHOD__));
@@ -135,21 +129,21 @@ class ShowController extends Controller
throw new NotFoundHttpException();
}
$manager = $this->getManager();
$manager = $this->getManager();
// get list of attachments. Count it and split it.
$collection = $this->repository->get();
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
$collection = $this->repository->get();
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator->setPath(route('api.v1.attachments.index').$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer = app(AttachmentTransformer::class);
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -53,16 +53,14 @@ class StoreController extends Controller
{
parent::__construct();
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -50,16 +50,14 @@ class UpdateController extends Controller
{
parent::__construct();
$this->middleware(ApiDemoUser::class)->except(['delete', 'download', 'show', 'index']);
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -50,16 +50,14 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
$this->abRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
$this->abRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -70,35 +68,29 @@ class ShowController extends Controller
*/
public function index(PaginationDateRangeRequest $request): JsonResponse
{
$manager = $this->getManager();
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
'start' => $start,
'end' => $end,
] = $request->attributes->all();
$manager = $this->getManager();
['limit' => $limit, 'offset' => $offset, 'page' => $page, 'start' => $start, 'end' => $end] = $request->attributes->all();
// get list of available budgets. Count it and split it.
$collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);
$count = $collection->count();
$availableBudgets = $collection->slice($offset, $limit);
$collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);
$count = $collection->count();
$availableBudgets = $collection->slice($offset, $limit);
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new AvailableBudgetEnrichment();
$admin = auth()->user();
$enrichment = new AvailableBudgetEnrichment();
$enrichment->setUser($admin);
$availableBudgets = $enrichment->enrich($availableBudgets);
$availableBudgets = $enrichment->enrich($availableBudgets);
// make paginator:
$paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);
$paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);
$paginator->setPath(route('api.v1.available-budgets.index').$this->buildParams());
/** @var AvailableBudgetTransformer $transformer */
$transformer = app(AvailableBudgetTransformer::class);
$transformer = app(AvailableBudgetTransformer::class);
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
$resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -126,7 +118,6 @@ class ShowController extends Controller
$enrichment->setUser($admin);
$availableBudget = $enrichment->enrichSingle($availableBudget);
$resource = new Item($availableBudget, $transformer, 'available_budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -56,14 +56,12 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -74,25 +72,21 @@ class ListController extends Controller
*/
public function attachments(PaginationRequest $request, Bill $bill): JsonResponse
{
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
$manager = $this->getManager();
$collection = $this->repository->getAttachments($bill);
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
$manager = $this->getManager();
$collection = $this->repository->getAttachments($bill);
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
$count = $collection->count();
$attachments = $collection->slice($offset, $limit);
// make paginator:
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
$paginator->setPath(route('api.v1.bills.attachments', [$bill->id]).$this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer = app(AttachmentTransformer::class);
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -106,24 +100,20 @@ class ListController extends Controller
*/
public function rules(PaginationRequest $request, Bill $bill): JsonResponse
{
[
'limit' => $limit,
'offset' => $offset,
'page' => $page,
] = $request->attributes->all();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
$manager = $this->getManager();
$collection = $this->repository->getRulesForBill($bill);
$count = $collection->count();
$rules = $collection->slice($offset, $limit);
$manager = $this->getManager();
$collection = $this->repository->getRulesForBill($bill);
$count = $collection->count();
$rules = $collection->slice($offset, $limit);
// make paginator:
$paginator = new LengthAwarePaginator($rules, $count, $limit, $page);
$paginator = new LengthAwarePaginator($rules, $count, $limit, $page);
$paginator->setPath(route('api.v1.bills.rules', [$bill->id]).$this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$resource = new FractalCollection($rules, $transformer, 'rules');
$transformer = app(RuleTransformer::class);
$resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -137,22 +127,16 @@ class ListController extends Controller
*/
public function transactions(PaginationDateRangeRequest $request, Bill $bill): JsonResponse
{
[
'limit' => $limit,
'page' => $page,
'types' => $types,
'start' => $start,
'end' => $end,
] = $request->attributes->all();
['limit' => $limit, 'page' => $page, 'types' => $types, 'start' => $start, 'end' => $end] = $request->attributes->all();
$manager = $this->getManager();
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
$admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// include source + destination account name and type.
@@ -175,18 +159,18 @@ class ListController extends Controller
}
// get paginator.
$paginator = $collector->getPaginatedGroups();
$paginator = $collector->getPaginatedGroups();
$paginator->setPath(route('api.v1.bills.transactions', [$bill->id]).$this->buildParams());
// enrich
$enrichment = new TransactionGroupEnrichment();
$enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer = app(TransactionGroupTransformer::class);
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -51,14 +51,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -69,34 +67,28 @@ class ShowController extends Controller
*/
public function index(PaginationDateRangeRequest $request): JsonResponse
{
[
'limit' => $limit,
'offset' => $offset,
'start' => $start,
'end' => $end,
'page' => $page,
] = $request->attributes->all();
['limit' => $limit, 'offset' => $offset, 'start' => $start, 'end' => $end, 'page' => $page] = $request->attributes->all();
$this->repository->correctOrder();
$bills = $this->repository->getBills();
$manager = $this->getManager();
$count = $bills->count();
$bills = $bills->slice($offset, $limit);
$paginator = new LengthAwarePaginator($bills, $count, $limit, $page);
$bills = $this->repository->getBills();
$manager = $this->getManager();
$count = $bills->count();
$bills = $bills->slice($offset, $limit);
$paginator = new LengthAwarePaginator($bills, $count, $limit, $page);
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($start);
$enrichment->setEnd($end);
$bills = $enrichment->enrich($bills);
$bills = $enrichment->enrich($bills);
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer = app(BillTransformer::class);
$resource = new FractalCollection($bills, $transformer, 'bills');
$resource = new FractalCollection($bills, $transformer, 'bills');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -110,26 +102,23 @@ class ShowController extends Controller
*/
public function show(DateRangeRequest $request, Bill $bill): JsonResponse
{
[
'start' => $start,
'end' => $end,
] = $request->attributes->all();
['start' => $start, 'end' => $end] = $request->attributes->all();
$manager = $this->getManager();
$manager = $this->getManager();
// enrich
/** @var User $admin */
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
$admin = auth()->user();
$enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($start);
$enrichment->setEnd($end);
$bill = $enrichment->enrichSingle($bill);
$bill = $enrichment->enrichSingle($bill);
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer = app(BillTransformer::class);
$resource = new Item($bill, $transformer, 'bills');
$resource = new Item($bill, $transformer, 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -50,14 +50,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BillRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -49,7 +49,7 @@ class ListController extends Controller
use TransactionFilter;
private BudgetLimitRepositoryInterface $blRepository;
private BudgetRepositoryInterface $repository;
private BudgetRepositoryInterface $repository;
/**
* ListController constructor.
@@ -57,16 +57,14 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -120,7 +118,6 @@ class ListController extends Controller
$enrichment->setUser($admin);
$budgetLimits = $enrichment->enrich($budgetLimits);
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);
@@ -43,7 +43,7 @@ use League\Fractal\Resource\Item;
class ShowController extends Controller
{
private BudgetLimitRepositoryInterface $blRepository;
private BudgetRepositoryInterface $repository;
private BudgetRepositoryInterface $repository;
/**
* ListController constructor.
@@ -51,16 +51,14 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,14 +47,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
public function update(UpdateRequest $request, Budget $budget): JsonResponse
@@ -46,16 +46,14 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,7 +47,7 @@ use League\Fractal\Resource\Item;
class ShowController extends Controller
{
private BudgetLimitRepositoryInterface $blRepository;
private BudgetRepositoryInterface $repository;
private BudgetRepositoryInterface $repository;
/**
* BudgetLimitController constructor.
@@ -55,18 +55,16 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser($user);
$this->blRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser($user);
$this->blRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -88,7 +86,6 @@ class ShowController extends Controller
/** @var Budget $budget */
$budget = $enrichment->enrichSingle($budget);
$manager = $this->getManager();
$manager->parseIncludes('budget');
$pageSize = $this->parameters->get('limit');
@@ -47,16 +47,14 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -52,16 +52,14 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->blRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -54,14 +54,12 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -49,14 +49,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,14 +47,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CategoryRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\DestroyRequest;
@@ -35,26 +34,26 @@ use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class DestroyController extends Controller
{
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function destroy(DestroyRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse
@@ -24,13 +24,13 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\ExchangeRateTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
/**
@@ -41,20 +41,19 @@ class IndexController extends Controller
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function index(): JsonResponse
@@ -67,9 +66,6 @@ class IndexController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
}
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Enums\UserRoleEnum;
@@ -34,6 +33,7 @@ use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\ExchangeRateTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@@ -45,20 +45,19 @@ class ShowController extends Controller
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function show(TransactionCurrency $from, TransactionCurrency $to): JsonResponse
@@ -73,10 +72,7 @@ class ShowController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function showSingleById(CurrencyExchangeRate $exchangeRate): JsonResponse
@@ -84,10 +80,7 @@ class ShowController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters);
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function showSingleByDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): JsonResponse
@@ -100,9 +93,6 @@ class ShowController extends Controller
throw new NotFoundHttpException();
}
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
}
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\StoreByCurrenciesRequest;
@@ -38,6 +37,7 @@ use FireflyIII\Support\Facades\Amount;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\ExchangeRateTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
@@ -45,26 +45,24 @@ class StoreController extends Controller
{
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function storeByCurrencies(StoreByCurrenciesRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse
{
$data = $request->getAll();
$collection = new Collection();
@@ -87,15 +85,11 @@ class StoreController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function storeByDate(StoreByDateRequest $request, Carbon $date): JsonResponse
{
$data = $request->getAll();
$from = $request->getFromCurrency();
$collection = new Collection();
@@ -118,10 +112,7 @@ class StoreController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
return response()
->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function store(StoreRequest $request): JsonResponse
@@ -145,9 +136,6 @@ class StoreController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters);
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $rate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $rate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
}
@@ -24,7 +24,6 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\CurrencyExchangeRate;
use Illuminate\Http\Request;
use Carbon\Carbon;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\CurrencyExchangeRate\UpdateRequest;
@@ -35,27 +34,27 @@ use FireflyIII\Repositories\ExchangeRate\ExchangeRateRepositoryInterface;
use FireflyIII\Support\Http\Api\ValidatesUserGroupTrait;
use FireflyIII\Transformers\ExchangeRateTransformer;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class UpdateController extends Controller
{
use ValidatesUserGroupTrait;
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
public const string RESOURCE_KEY = 'exchange-rates';
protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
$this->middleware(function (Request $request, $next) {
$this->repository = app(ExchangeRateRepositoryInterface::class);
$this->repository->setUserGroup($this->validateUserGroup($request));
return $next($request);
}
);
return $next($request);
});
}
public function updateById(UpdateRequest $request, CurrencyExchangeRate $exchangeRate): JsonResponse
@@ -66,10 +65,7 @@ class UpdateController extends Controller
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters);
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
public function updateByDate(UpdateRequest $request, TransactionCurrency $from, TransactionCurrency $to, Carbon $date): JsonResponse
@@ -84,9 +80,6 @@ class UpdateController extends Controller
$transformer = new ExchangeRateTransformer();
return response()
->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))
->header('Content-Type', self::CONTENT_TYPE)
;
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
}
@@ -44,16 +44,14 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -50,16 +50,14 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -48,16 +48,14 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -46,16 +46,14 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -51,14 +51,12 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -49,14 +49,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -114,7 +112,6 @@ class ShowController extends Controller
$enrichment->setUser($admin);
$piggyBank = $enrichment->enrichSingle($piggyBank);
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($this->parameters);
@@ -47,14 +47,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(PiggyBankRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -43,14 +43,12 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -52,14 +52,12 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -49,14 +49,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,14 +47,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -1,6 +1,7 @@
<?php
declare(strict_types=1);
/*
* TriggerController.php
* Copyright (c) 2025 james@firefly-iii.org
@@ -50,14 +51,12 @@ class TriggerController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
public function trigger(SingleDateRequest $request, Recurrence $recurrence): JsonResponse
@@ -95,11 +94,7 @@ class TriggerController extends Controller
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
->setIds($groups->pluck('id')->toArray())
->withAPIInformation()
;
$collector->setUser($admin)->setIds($groups->pluck('id')->toArray())->withAPIInformation();
$paginator = $collector->getPaginatedGroups();
}
@@ -47,14 +47,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(RecurringRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -44,17 +44,15 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -41,8 +41,6 @@ class ExpressionController extends Controller
*/
public function validateExpression(ValidateExpressionRequest $request): JsonResponse
{
return response()->json([
'valid' => true,
]);
return response()->json(['valid' => true]);
}
}
@@ -48,17 +48,15 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -45,17 +45,15 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -52,17 +52,15 @@ class TriggerController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -80,15 +78,15 @@ class TriggerController extends Controller
// overrule the rule(s) if necessary.
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
}
if (array_key_exists('end', $parameters) && null !== $parameters['end']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
}
if (array_key_exists('accounts', $parameters) && '' !== $parameters['accounts']) {
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// file the rule(s)
@@ -134,15 +132,15 @@ class TriggerController extends Controller
// overrule the rule(s) if necessary.
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
}
if (array_key_exists('end', $parameters) && null !== $parameters['end']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
}
if (array_key_exists('accounts', $parameters) && is_array($parameters['accounts']) && count($parameters['accounts']) > 0) {
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// fire the rule(s)
@@ -46,17 +46,15 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -44,17 +44,15 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -47,17 +47,15 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -48,17 +48,15 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -38,7 +38,7 @@ use League\Fractal\Resource\Item;
*/
class StoreController extends Controller
{
private AccountRepositoryInterface $accountRepository;
private AccountRepositoryInterface $accountRepository;
private RuleGroupRepositoryInterface $ruleGroupRepository;
/**
@@ -47,20 +47,18 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->accountRepository = app(AccountRepositoryInterface::class);
$this->accountRepository->setUser($user);
$this->accountRepository = app(AccountRepositoryInterface::class);
$this->accountRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -53,17 +53,15 @@ class TriggerController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -87,15 +85,15 @@ class TriggerController extends Controller
// overrule the rule(s) if necessary.
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
}
if (array_key_exists('end', $parameters) && null !== $parameters['end']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
}
if (array_key_exists('accounts', $parameters) && '' !== $parameters['accounts']) {
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// file the rule(s)
@@ -148,15 +146,15 @@ class TriggerController extends Controller
// overrule the rule(s) if necessary.
if (array_key_exists('start', $parameters) && null !== $parameters['start']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_after', 'value' => $parameters['start']->format('Y-m-d')]);
}
if (array_key_exists('end', $parameters) && null !== $parameters['end']) {
// add a range:
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
$ruleEngine->addOperator(['type' => 'date_before', 'value' => $parameters['end']->format('Y-m-d')]);
}
if (array_key_exists('accounts', $parameters) && is_array($parameters['accounts']) && count($parameters['accounts']) > 0) {
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
$ruleEngine->addOperator(['type' => 'account_id', 'value' => implode(',', $parameters['accounts'])]);
}
// file the rule(s)
@@ -36,7 +36,7 @@ use League\Fractal\Resource\Item;
/**
* Class UpdateController
*/
class UpdateController extends Controller
final class UpdateController extends Controller
{
private RuleGroupRepositoryInterface $ruleGroupRepository;
@@ -46,17 +46,15 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -44,17 +44,15 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -54,17 +54,15 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -143,7 +141,6 @@ class ListController extends Controller
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
@@ -48,17 +48,15 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -45,17 +45,15 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -46,17 +46,15 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -51,20 +51,18 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->repository = app(JournalRepositoryInterface::class);
$this->repository->setUser($admin);
$this->repository = app(JournalRepositoryInterface::class);
$this->repository->setUser($admin);
$this->groupRepository = app(TransactionGroupRepository::class);
$this->groupRepository->setUser($admin);
$this->groupRepository = app(TransactionGroupRepository::class);
$this->groupRepository->setUser($admin);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -52,17 +52,15 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->journalAPIRepository = app(JournalAPIRepositoryInterface::class);
$this->journalAPIRepository->setUser($admin);
$this->journalAPIRepository = app(JournalAPIRepositoryInterface::class);
$this->journalAPIRepository->setUser($admin);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -144,7 +144,6 @@ class ShowController extends Controller
$enrichment->setUser($admin);
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
@@ -24,11 +24,11 @@ declare(strict_types=1);
namespace FireflyIII\Api\V1\Controllers\Models\Transaction;
use Illuminate\Http\Request;
use FireflyIII\Api\V1\Controllers\Controller;
use FireflyIII\Api\V1\Requests\Models\Transaction\StoreRequest;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\Events\StoredTransactionGroup;
use FireflyIII\Events\Model\TransactionGroup\CreatedSingleTransactionGroup;
use FireflyIII\Events\Model\TransactionGroup\TransactionGroupEventFlags;
use FireflyIII\Exceptions\DuplicateTransactionException;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
@@ -40,6 +40,7 @@ use FireflyIII\Support\JsonApi\Enrichments\TransactionGroupEnrichment;
use FireflyIII\Transformers\TransactionGroupTransformer;
use FireflyIII\User;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
@@ -63,19 +64,17 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function (Request $request, $next) {
/** @var User $admin */
$admin = auth()->user();
$userGroup = $this->validateUserGroup($request);
$this->middleware(function (Request $request, $next) {
/** @var User $admin */
$admin = auth()->user();
$userGroup = $this->validateUserGroup($request);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
$this->groupRepository->setUserGroup($userGroup);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
$this->groupRepository->setUserGroup($userGroup);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -89,10 +88,9 @@ class StoreController extends Controller
public function store(StoreRequest $request): JsonResponse
{
Log::debug('Now in API StoreController::store()');
$data = $request->getAll();
$data['user'] = auth()->user();
$data['user_group'] = $this->userGroup;
$data = $request->getAll();
$data['user'] = auth()->user();
$data['user_group'] = $this->userGroup;
Log::channel('audit')->info('Store new transaction over API.', $data);
@@ -112,18 +110,21 @@ class StoreController extends Controller
throw new ValidationException($validator);
}
Preferences::mark();
$applyRules = $data['apply_rules'] ?? true;
$fireWebhooks = $data['fire_webhooks'] ?? true;
event(new StoredTransactionGroup($transactionGroup, $applyRules, $fireWebhooks));
$flags = new TransactionGroupEventFlags();
$flags->applyRules = $data['apply_rules'] ?? true;
$flags->fireWebhooks = $data['fire_webhooks'] ?? true;
$flags->batchSubmission = $data['batch_submission'] ?? false;
Log::debug('CreatedSingleTransactionGroup');
event(new CreatedSingleTransactionGroup($transactionGroup, $flags));
$manager = $this->getManager();
$manager = $this->getManager();
/** @var User $admin */
$admin = auth()->user();
$admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
$collector = app(GroupCollectorInterface::class);
$collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
->setUserGroup($this->userGroup)
@@ -133,20 +134,20 @@ class StoreController extends Controller
->withAPIInformation()
;
$selectedGroup = $collector->getGroups()->first();
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw HttpException::fromStatusCode(410, '200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
}
// enrich
$enrichment = new TransactionGroupEnrichment();
$enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
/** @var TransactionGroupTransformer $transformer */
$transformer = app(TransactionGroupTransformer::class);
$transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
$resource = new Item($selectedGroup, $transformer, 'transactions');
$resource = new Item($selectedGroup, $transformer, 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -52,17 +52,15 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $admin */
$admin = auth()->user();
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -84,6 +82,9 @@ class UpdateController extends Controller
$applyRules = $data['apply_rules'] ?? true;
$fireWebhooks = $data['fire_webhooks'] ?? true;
$runRecalculations = $oldHash !== $newHash;
// FIXME responds to a single event.
// flags in array?
event(new UpdatedTransactionGroup($transactionGroup, $applyRules, $fireWebhooks, $runRecalculations));
/** @var User $admin */
@@ -41,7 +41,7 @@ use Illuminate\Validation\ValidationException;
class DestroyController extends Controller
{
private CurrencyRepositoryInterface $repository;
private UserRepositoryInterface $userRepository;
private UserRepositoryInterface $userRepository;
/**
* CurrencyRepository constructor.
@@ -49,15 +49,13 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -89,13 +89,11 @@ class ListController extends Controller
$unfiltered = $accountRepository->getAccountsByType($types);
// filter list on currency preference:
$collection = $unfiltered->filter(
static function (Account $account) use ($currency, $accountRepository): bool {
$currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
$collection = $unfiltered->filter(static function (Account $account) use ($currency, $accountRepository): bool {
$currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
return $currencyId === $currency->id;
}
);
return $currencyId === $currency->id;
});
$count = $collection->count();
$accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@@ -177,9 +175,7 @@ class ListController extends Controller
$unfiltered = $billRepos->getBills();
// filter and paginate list:
$collection = $unfiltered->filter(
static fn (Bill $bill): bool => $bill->transaction_currency_id === $currency->id
);
$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);
@@ -260,15 +256,16 @@ class ListController extends Controller
$unfiltered = $recurringRepos->get();
// filter selection
$collection = $unfiltered->filter(
static function (Recurrence $recurrence) use ($currency): ?Recurrence { // @phpstan-ignore-line
if (array_any($recurrence->recurrenceTransactions, static fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id)) {
return $recurrence;
}
return null;
$collection = $unfiltered->filter(static function (Recurrence $recurrence) use ($currency): null|Recurrence { // @phpstan-ignore-line
if (array_any(
$recurrence->recurrenceTransactions,
static fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id
)) {
return $recurrence;
}
);
return null;
});
$count = $collection->count();
$recurrences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@@ -309,15 +306,16 @@ class ListController extends Controller
$ruleRepos = app(RuleRepositoryInterface::class);
$unfiltered = $ruleRepos->getAll();
$collection = $unfiltered->filter(
static function (Rule $rule) use ($currency): ?Rule { // @phpstan-ignore-line
if (array_any($rule->ruleTriggers, static fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value)) {
return $rule;
}
return null;
$collection = $unfiltered->filter(static function (Rule $rule) use ($currency): null|Rule { // @phpstan-ignore-line
if (array_any(
$rule->ruleTriggers,
static fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value
)) {
return $rule;
}
);
return null;
});
$count = $collection->count();
$rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@@ -53,14 +53,12 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -51,14 +51,12 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -54,14 +54,12 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->middleware(function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository->setUser(auth()->user());
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -44,18 +44,16 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -49,18 +49,16 @@ class ShowController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -43,7 +43,7 @@ class StoreController extends Controller
{
use TransactionFilter;
private JournalRepositoryInterface $journalRepository;
private JournalRepositoryInterface $journalRepository;
private LinkTypeRepositoryInterface $repository;
/**
@@ -52,20 +52,18 @@ class StoreController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->repository->setUser($user);
$this->journalRepository->setUser($user);
$this->repository->setUser($user);
$this->journalRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -39,7 +39,7 @@ use League\Fractal\Resource\Item;
*/
class UpdateController extends Controller
{
private JournalRepositoryInterface $journalRepository;
private JournalRepositoryInterface $journalRepository;
private LinkTypeRepositoryInterface $repository;
/**
@@ -48,20 +48,18 @@ class UpdateController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
$this->repository->setUser($user);
$this->journalRepository->setUser($user);
$this->repository->setUser($user);
$this->journalRepository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -48,16 +48,14 @@ class DestroyController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**
@@ -52,16 +52,14 @@ class ListController extends Controller
public function __construct()
{
parent::__construct();
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
$this->middleware(function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->repository->setUser($user);
return $next($request);
}
);
return $next($request);
});
}
/**

Some files were not shown because too many files have changed in this diff Show More