mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-17 07:08:19 +00:00
Clean up some code.
This commit is contained in:
@@ -23,7 +23,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Http\Controllers\Recurring;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
||||
use FireflyIII\Http\Controllers\Controller;
|
||||
@@ -45,12 +44,9 @@ use Illuminate\View\View;
|
||||
*/
|
||||
class CreateController extends Controller
|
||||
{
|
||||
/** @var BudgetRepositoryInterface The budget repository */
|
||||
private $budgets;
|
||||
/** @var RecurringRepositoryInterface Recurring repository */
|
||||
private $recurring;
|
||||
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private RecurringRepositoryInterface $recurring;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
|
||||
/**
|
||||
* CreateController constructor.
|
||||
@@ -69,7 +65,7 @@ class CreateController extends Controller
|
||||
app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgets = app(BudgetRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
|
||||
return $next($request);
|
||||
@@ -83,7 +79,7 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function createFromJournal(Request $request, TransactionJournal $journal)
|
||||
{
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$tomorrow = today(config('app.timezone'));
|
||||
$oldRepetitionType = $request->old('repetition_type');
|
||||
@@ -177,7 +173,7 @@ class CreateController extends Controller
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
$defaultCurrency = app('amount')->getDefaultCurrency();
|
||||
$tomorrow = today(config('app.timezone'));
|
||||
$oldRepetitionType = $request->old('repetition_type');
|
||||
|
||||
@@ -46,11 +46,9 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
*/
|
||||
class EditController extends Controller
|
||||
{
|
||||
/** @var BudgetRepositoryInterface The budget repository */
|
||||
private $budgets;
|
||||
/** @var RecurringRepositoryInterface Recurring repository */
|
||||
private $recurring;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
private BudgetRepositoryInterface $budgetRepos;
|
||||
private RecurringRepositoryInterface $recurring;
|
||||
private AttachmentHelperInterface $attachments;
|
||||
|
||||
/**
|
||||
* EditController constructor.
|
||||
@@ -69,7 +67,7 @@ class EditController extends Controller
|
||||
app('view')->share('subTitle', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgets = app(BudgetRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
$this->attachments = app(AttachmentHelperInterface::class);
|
||||
return $next($request);
|
||||
}
|
||||
@@ -82,9 +80,9 @@ class EditController extends Controller
|
||||
* @param Request $request
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @return Factory|View
|
||||
* @throws FireflyException
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function edit(Request $request, Recurrence $recurrence)
|
||||
{
|
||||
@@ -93,7 +91,7 @@ class EditController extends Controller
|
||||
$transformer->setParameters(new ParameterBag);
|
||||
|
||||
$array = $transformer->transform($recurrence);
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgets->getActiveBudgets());
|
||||
$budgets = app('expandedform')->makeSelectListWithEmpty($this->budgetRepos->getActiveBudgets());
|
||||
|
||||
/** @var RecurrenceRepetition $repetition */
|
||||
$repetition = $recurrence->recurrenceRepetitions()->first();
|
||||
@@ -108,7 +106,7 @@ class EditController extends Controller
|
||||
}
|
||||
$request->session()->forget('recurrences.edit.fromUpdate');
|
||||
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnds = [
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
@@ -129,7 +127,7 @@ class EditController extends Controller
|
||||
];
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$preFilled = [
|
||||
$preFilled = [
|
||||
'transaction_type' => strtolower($recurrence->transactionType->type),
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,
|
||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,
|
||||
@@ -151,8 +149,8 @@ class EditController extends Controller
|
||||
* @param RecurrenceFormRequest $request
|
||||
* @param Recurrence $recurrence
|
||||
*
|
||||
* @throws FireflyException
|
||||
* @return RedirectResponse|Redirector
|
||||
* @throws FireflyException
|
||||
*/
|
||||
public function update(RecurrenceFormRequest $request, Recurrence $recurrence)
|
||||
{
|
||||
|
||||
@@ -45,8 +45,7 @@ use Symfony\Component\HttpFoundation\ParameterBag;
|
||||
class IndexController extends Controller
|
||||
{
|
||||
use GetConfigurationData;
|
||||
/** @var RecurringRepositoryInterface Recurring repository */
|
||||
private $recurring;
|
||||
private RecurringRepositoryInterface $recurringRepos;
|
||||
|
||||
/**
|
||||
* IndexController constructor.
|
||||
@@ -63,7 +62,7 @@ class IndexController extends Controller
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->recurringRepos = app(RecurringRepositoryInterface::class);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
@@ -84,13 +83,12 @@ class IndexController extends Controller
|
||||
{
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$collection = $this->recurring->get();
|
||||
$collection = $this->recurringRepos->get();
|
||||
$today = today(config('app.timezone'));
|
||||
$year = today(config('app.timezone'));
|
||||
|
||||
// split collection
|
||||
$total = $collection->count();
|
||||
/** @var Collection $recurrences */
|
||||
$recurrences = $collection->slice(($page - 1) * $pageSize, $pageSize);
|
||||
|
||||
/** @var RecurrenceTransformer $transformer */
|
||||
|
||||
Reference in New Issue
Block a user