Clean up some code.

This commit is contained in:
James Cole
2020-10-13 06:35:33 +02:00
parent 3bd5ac21c9
commit 4e51f0abc4
33 changed files with 149 additions and 294 deletions

View File

@@ -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)
{