mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-18 15:39:50 +00:00
Code cleanup
This commit is contained in:
@@ -62,8 +62,8 @@ class CreateController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string)trans('firefly.create_new_recurrence'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string) trans('firefly.create_new_recurrence'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
@@ -95,22 +95,22 @@ class CreateController extends Controller
|
||||
}
|
||||
$request->session()->forget('recurring.create.fromStore');
|
||||
$repetitionEnds = [
|
||||
'forever' => (string)trans('firefly.repeat_forever'),
|
||||
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||
'times' => (string)trans('firefly.repeat_times'),
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
'times' => (string) trans('firefly.repeat_times'),
|
||||
];
|
||||
$weekendResponses = [
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
||||
];
|
||||
$hasOldInput = null !== $request->old('_token'); // flash some data
|
||||
$preFilled = [
|
||||
'first_date' => $tomorrow->format('Y-m-d'),
|
||||
'transaction_type' => $hasOldInput ? $request->old('transaction_type') : 'withdrawal',
|
||||
'active' => $hasOldInput ? (bool)$request->old('active') : true,
|
||||
'apply_rules' => $hasOldInput ? (bool)$request->old('apply_rules') : true,
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : true,
|
||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : true,
|
||||
];
|
||||
$request->session()->flash('preFilled', $preFilled);
|
||||
|
||||
@@ -140,15 +140,15 @@ class CreateController extends Controller
|
||||
}
|
||||
$request->session()->forget('recurring.create.fromStore');
|
||||
$repetitionEnds = [
|
||||
'forever' => (string)trans('firefly.repeat_forever'),
|
||||
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||
'times' => (string)trans('firefly.repeat_times'),
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
'times' => (string) trans('firefly.repeat_times'),
|
||||
];
|
||||
$weekendResponses = [
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
||||
];
|
||||
|
||||
// fill prefilled with journal info
|
||||
@@ -181,8 +181,8 @@ class CreateController extends Controller
|
||||
'category' => $request->old('category'),
|
||||
'budget_id' => $request->old('budget_id'),
|
||||
'bill_id' => $request->old('bill_id'),
|
||||
'active' => (bool)$request->old('active'),
|
||||
'apply_rules' => (bool)$request->old('apply_rules'),
|
||||
'active' => (bool) $request->old('active'),
|
||||
'apply_rules' => (bool) $request->old('apply_rules'),
|
||||
];
|
||||
}
|
||||
if (false === $hasOldInput) {
|
||||
@@ -234,7 +234,7 @@ class CreateController extends Controller
|
||||
}
|
||||
Log::channel('audit')->info('Stored new recurrence.', $data);
|
||||
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_new_recurrence', ['title' => $recurrence->title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
// store attachment(s):
|
||||
@@ -245,7 +245,7 @@ class CreateController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
@@ -253,7 +253,7 @@ class CreateController extends Controller
|
||||
}
|
||||
|
||||
$redirect = redirect($this->getPreviousUrl('recurring.create.url'));
|
||||
if (1 === (int)$request->get('create_another')) {
|
||||
if (1 === (int) $request->get('create_another')) {
|
||||
// set value so create routine will not overwrite URL:
|
||||
$request->session()->put('recurring.create.fromStore', true);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class DeleteController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
|
||||
@@ -68,7 +68,7 @@ class DeleteController extends Controller
|
||||
*/
|
||||
public function delete(Recurrence $recurrence)
|
||||
{
|
||||
$subTitle = (string)trans('firefly.delete_recurring', ['title' => $recurrence->title]);
|
||||
$subTitle = (string) trans('firefly.delete_recurring', ['title' => $recurrence->title]);
|
||||
// put previous url in session
|
||||
$this->rememberPreviousUrl('recurrences.delete.url');
|
||||
|
||||
@@ -85,7 +85,7 @@ class DeleteController extends Controller
|
||||
public function destroy(RecurringRepositoryInterface $repository, Request $request, Recurrence $recurrence)
|
||||
{
|
||||
$repository->destroy($recurrence);
|
||||
$request->session()->flash('success', (string)trans('firefly.recurrence_deleted', ['title' => $recurrence->title]));
|
||||
$request->session()->flash('success', (string) trans('firefly.recurrence_deleted', ['title' => $recurrence->title]));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect($this->getPreviousUrl('recurrences.delete.url'));
|
||||
|
||||
@@ -63,8 +63,8 @@ class EditController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
app('view')->share('subTitle', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
$this->budgetRepos = app(BudgetRepositoryInterface::class);
|
||||
@@ -114,9 +114,9 @@ class EditController extends Controller
|
||||
|
||||
$repetitionEnd = 'forever';
|
||||
$repetitionEnds = [
|
||||
'forever' => (string)trans('firefly.repeat_forever'),
|
||||
'until_date' => (string)trans('firefly.repeat_until_date'),
|
||||
'times' => (string)trans('firefly.repeat_times'),
|
||||
'forever' => (string) trans('firefly.repeat_forever'),
|
||||
'until_date' => (string) trans('firefly.repeat_until_date'),
|
||||
'times' => (string) trans('firefly.repeat_times'),
|
||||
];
|
||||
if (null !== $recurrence->repeat_until) {
|
||||
$repetitionEnd = 'until_date';
|
||||
@@ -126,22 +126,22 @@ class EditController extends Controller
|
||||
}
|
||||
|
||||
$weekendResponses = [
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string)trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string)trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string)trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string)trans('firefly.jump_to_monday'),
|
||||
RecurrenceRepetition::WEEKEND_DO_NOTHING => (string) trans('firefly.do_nothing'),
|
||||
RecurrenceRepetition::WEEKEND_SKIP_CREATION => (string) trans('firefly.skip_transaction'),
|
||||
RecurrenceRepetition::WEEKEND_TO_FRIDAY => (string) trans('firefly.jump_to_friday'),
|
||||
RecurrenceRepetition::WEEKEND_TO_MONDAY => (string) trans('firefly.jump_to_monday'),
|
||||
];
|
||||
|
||||
$hasOldInput = null !== $request->old('_token');
|
||||
$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,
|
||||
'active' => $hasOldInput ? (bool) $request->old('active') : $recurrence->active,
|
||||
'apply_rules' => $hasOldInput ? (bool) $request->old('apply_rules') : $recurrence->apply_rules,
|
||||
'deposit_source_id' => $array['transactions'][0]['source_id'],
|
||||
'withdrawal_destination_id' => $array['transactions'][0]['destination_id'],
|
||||
];
|
||||
$array['first_date'] = substr((string)$array['first_date'], 0, 10);
|
||||
$array['repeat_until'] = substr((string)$array['repeat_until'], 0, 10);
|
||||
$array['first_date'] = substr((string) $array['first_date'], 0, 10);
|
||||
$array['repeat_until'] = substr((string) $array['repeat_until'], 0, 10);
|
||||
$array['transactions'][0]['tags'] = implode(',', $array['transactions'][0]['tags'] ?? []);
|
||||
|
||||
return view(
|
||||
@@ -172,7 +172,7 @@ class EditController extends Controller
|
||||
$data = $request->getAll();
|
||||
$this->recurring->update($recurrence, $data);
|
||||
|
||||
$request->session()->flash('success', (string)trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
|
||||
$request->session()->flash('success', (string) trans('firefly.updated_recurrence', ['title' => $recurrence->title]));
|
||||
Log::channel('audit')->info(sprintf('Updated recurrence #%d.', $recurrence->id), $data);
|
||||
|
||||
// store new attachment(s):
|
||||
@@ -183,7 +183,7 @@ class EditController extends Controller
|
||||
}
|
||||
if (null !== $files && auth()->user()->hasRole('demo')) {
|
||||
Log::channel('audit')->warning(sprintf('The demo user is trying to upload attachments in %s.', __METHOD__));
|
||||
session()->flash('info', (string)trans('firefly.no_att_demo_user'));
|
||||
session()->flash('info', (string) trans('firefly.no_att_demo_user'));
|
||||
}
|
||||
|
||||
if (count($this->attachments->getMessages()->get('attachments')) > 0) {
|
||||
@@ -191,7 +191,7 @@ class EditController extends Controller
|
||||
}
|
||||
app('preferences')->mark();
|
||||
$redirect = redirect($this->getPreviousUrl('recurrences.edit.url'));
|
||||
if (1 === (int)$request->get('return_to_edit')) {
|
||||
if (1 === (int) $request->get('return_to_edit')) {
|
||||
// set value so edit routine will not overwrite URL:
|
||||
$request->session()->put('recurrences.edit.fromUpdate', true);
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class IndexController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurringRepos = app(RecurringRepositoryInterface::class);
|
||||
|
||||
@@ -75,8 +75,8 @@ class IndexController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
|
||||
$pageSize = (int)app('preferences')->get('listPageSize', 50)->data;
|
||||
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
|
||||
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
|
||||
$collection = $this->recurringRepos->get();
|
||||
$today = today(config('app.timezone'));
|
||||
$year = today(config('app.timezone'));
|
||||
|
||||
@@ -60,7 +60,7 @@ class ShowController extends Controller
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('mainTitleIcon', 'fa-paint-brush');
|
||||
app('view')->share('title', (string)trans('firefly.recurrences'));
|
||||
app('view')->share('title', (string) trans('firefly.recurrences'));
|
||||
|
||||
$this->recurring = app(RecurringRepositoryInterface::class);
|
||||
|
||||
@@ -125,7 +125,7 @@ class ShowController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$subTitle = (string)trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
|
||||
$subTitle = (string) trans('firefly.overview_for_recurrence', ['title' => $recurrence->title]);
|
||||
|
||||
return view('recurring.show', compact('recurrence', 'subTitle', 'array', 'groups', 'today'));
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ class TriggerController extends Controller
|
||||
app('preferences')->mark();
|
||||
|
||||
if (0 === $groups->count()) {
|
||||
$request->session()->flash('info', (string)trans('firefly.no_new_transaction_in_recurrence'));
|
||||
$request->session()->flash('info', (string) trans('firefly.no_new_transaction_in_recurrence'));
|
||||
}
|
||||
if (1 === $groups->count()) {
|
||||
$first = $groups->first();
|
||||
$request->session()->flash('success', (string)trans('firefly.stored_journal_no_descr'));
|
||||
$request->session()->flash('success', (string) trans('firefly.stored_journal_no_descr'));
|
||||
$request->session()->flash('success_url', route('transactions.show', [$first->id]));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user