Skip to content

Firefly III: a personal finances manager

Catch link error.

James Colec37ade8f5b40
diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php
index 09036ea562..0b560c78c8 100644
--- a/app/Http/Controllers/Transaction/LinkController.php
+++ b/app/Http/Controllers/Transaction/LinkController.php
@@ -83,13 +83,6 @@ class LinkController extends Controller
return redirect(strval(session('journal_links.delete.uri')));
}
- public function switch(LinkTypeRepositoryInterface $repository, TransactionJournalLink $link) {
-
- $repository->switchLink($link);
-
- return redirect(URL::previous());
- }
-
/**
* @param JournalLinkRequest $request
* @param LinkTypeRepositoryInterface $repository
@@ -127,8 +120,14 @@ class LinkController extends Controller
$linkJournalId = intval($request->string('link_other'));
}
+
$opposing = $journalRepository->find($linkJournalId);
- $result = $repository->findLink($journal, $opposing);
+ if (is_null($opposing->id)) {
+ Session::flash('error', trans('firefly.invalid_link_data'));
+
+ return redirect(route('transactions.show', $journal->id));
+ }
+ $result = $repository->findLink($journal, $opposing);
if ($result) {
Session::flash('error', trans('firefly.journals_error_linked'));
@@ -155,4 +154,12 @@ class LinkController extends Controller
return redirect(route('transactions.show', $journal->id));
}
+ public function switch(LinkTypeRepositoryInterface $repository, TransactionJournalLink $link)
+ {
+
+ $repository->switchLink($link);
+
+ return redirect(URL::previous());
+ }
+
}
\ No newline at end of file