data; View::share('IS_DEMO_SITE', $isDemoSite); View::share('DEMO_USERNAME', env('DEMO_USERNAME', '')); View::share('DEMO_PASSWORD', env('DEMO_PASSWORD', '')); // translations: $this->middleware( function ($request, $next) { $this->monthFormat = (string)trans('config.month'); $this->monthAndDayFormat = (string)trans('config.month_and_day'); $this->dateTimeFormat = (string)trans('config.date_time'); return $next($request); } ); } /** * Functionality: * * - If the $identifier contains the word "delete" then a remembered uri with the text "/show/" in it will not be returned but instead the index (/) * will be returned. * - If the remembered uri contains "javascript/" the remembered uri will not be returned but instead the index (/) will be returned. * * @param string $identifier * * @return string */ protected function getPreviousUri(string $identifier): string { $uri = strval(session($identifier)); if (!(strpos($identifier, 'delete') === false) && !(strpos($uri, '/show/') === false)) { $uri = route('index'); } if (!(strpos($uri, 'javascript') === false)) { $uri = route('index'); } return $uri; } /** * @param TransactionJournal $journal * * @return bool */ protected function isOpeningBalance(TransactionJournal $journal): bool { return $journal->transactionTypeStr() === TransactionType::OPENING_BALANCE; } /** * @param TransactionJournal $journal * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ protected function redirectToAccount(TransactionJournal $journal) { $valid = [AccountType::DEFAULT, AccountType::ASSET]; $transactions = $journal->transactions; /** @var Transaction $transaction */ foreach ($transactions as $transaction) { $account = $transaction->account; if (in_array($account->accountType->type, $valid)) { return redirect(route('accounts.show', [$account->id])); } } // @codeCoverageIgnoreStart Session::flash('error', strval(trans('firefly.cannot_redirect_to_account'))); return redirect(route('index')); // @codeCoverageIgnoreEnd } /** * @param string $identifier */ protected function rememberPreviousUri(string $identifier) { Session::put($identifier, URL::previous()); } }