mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-24 14:46:37 +00:00
Code cleanup that (hopefully) matches style CI
This commit is contained in:
@@ -29,6 +29,8 @@ use FireflyIII\Models\TransactionJournalLink;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
use URL;
|
||||
@@ -45,6 +47,7 @@ class LinkController extends Controller
|
||||
|
||||
/**
|
||||
* LinkController constructor.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -53,7 +56,7 @@ class LinkController extends Controller
|
||||
// some useful repositories:
|
||||
$this->middleware(
|
||||
function ($request, $next) {
|
||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||
app('view')->share('title', (string) trans('firefly.transactions'));
|
||||
app('view')->share('mainTitleIcon', 'fa-repeat');
|
||||
|
||||
$this->journalRepository = app(JournalRepositoryInterface::class);
|
||||
@@ -64,17 +67,6 @@ class LinkController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function modal(TransactionJournal $journal)
|
||||
{
|
||||
$linkTypes = $this->repository->get();
|
||||
|
||||
return view('transactions.links.modal', compact('journal', 'linkTypes'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a link.
|
||||
*
|
||||
@@ -85,7 +77,7 @@ class LinkController extends Controller
|
||||
public function delete(TransactionJournalLink $link)
|
||||
{
|
||||
$subTitleIcon = 'fa-link';
|
||||
$subTitle = (string)trans('breadcrumbs.delete_journal_link');
|
||||
$subTitle = (string) trans('breadcrumbs.delete_journal_link');
|
||||
$this->rememberPreviousUri('journal_links.delete.uri');
|
||||
|
||||
return view('transactions.links.delete', compact('link', 'subTitle', 'subTitleIcon'));
|
||||
@@ -96,16 +88,28 @@ class LinkController extends Controller
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function destroy(TransactionJournalLink $link)
|
||||
{
|
||||
$this->repository->destroyLink($link);
|
||||
|
||||
session()->flash('success', (string)trans('firefly.deleted_link'));
|
||||
session()->flash('success', (string) trans('firefly.deleted_link'));
|
||||
app('preferences')->mark();
|
||||
|
||||
return redirect((string)session('journal_links.delete.uri'));
|
||||
return redirect((string) session('journal_links.delete.uri'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return Factory|View
|
||||
*/
|
||||
public function modal(TransactionJournal $journal)
|
||||
{
|
||||
$linkTypes = $this->repository->get();
|
||||
|
||||
return view('transactions.links.modal', compact('journal', 'linkTypes'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,16 +118,16 @@ class LinkController extends Controller
|
||||
* @param JournalLinkRequest $request
|
||||
* @param TransactionJournal $journal
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function store(JournalLinkRequest $request, TransactionJournal $journal)
|
||||
{
|
||||
$linkInfo = $request->getLinkInfo();
|
||||
|
||||
Log::debug('We are here (store)');
|
||||
$other = $this->journalRepository->findNull($linkInfo['transaction_journal_id']);
|
||||
$other = $this->journalRepository->findNull($linkInfo['transaction_journal_id']);
|
||||
if (null === $other) {
|
||||
session()->flash('error', (string)trans('firefly.invalid_link_selection'));
|
||||
session()->flash('error', (string) trans('firefly.invalid_link_selection'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
@@ -131,19 +135,19 @@ class LinkController extends Controller
|
||||
$alreadyLinked = $this->repository->findLink($journal, $other);
|
||||
|
||||
if ($other->id === $journal->id) {
|
||||
session()->flash('error', (string)trans('firefly.journals_link_to_self'));
|
||||
session()->flash('error', (string) trans('firefly.journals_link_to_self'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
|
||||
if ($alreadyLinked) {
|
||||
session()->flash('error', (string)trans('firefly.journals_error_linked'));
|
||||
session()->flash('error', (string) trans('firefly.journals_error_linked'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
Log::debug(sprintf('Journal is %d, opposing is %d', $journal->id, $other->id));
|
||||
$this->repository->storeLink($linkInfo, $other, $journal);
|
||||
session()->flash('success', (string)trans('firefly.journals_linked'));
|
||||
session()->flash('success', (string) trans('firefly.journals_linked'));
|
||||
|
||||
return redirect(route('transactions.show', [$journal->transaction_group_id]));
|
||||
}
|
||||
@@ -153,7 +157,7 @@ class LinkController extends Controller
|
||||
*
|
||||
* @param TransactionJournalLink $link
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function switchLink(TransactionJournalLink $link)
|
||||
{
|
||||
|
Reference in New Issue
Block a user