mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-04 03:43:07 +00:00
Switch things.
This commit is contained in:
@@ -30,6 +30,7 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||
use Illuminate\Contracts\View\Factory;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Routing\Redirector;
|
||||
use Illuminate\View\View;
|
||||
use Log;
|
||||
@@ -157,9 +158,10 @@ class LinkController extends Controller
|
||||
*
|
||||
* @return RedirectResponse|Redirector
|
||||
*/
|
||||
public function switchLink(TransactionJournalLink $link)
|
||||
public function switchLink(Request $request)
|
||||
{
|
||||
$this->repository->switchLink($link);
|
||||
$linkId = (int)$request->get('id');
|
||||
$this->repository->switchLinkById($linkId);
|
||||
|
||||
return redirect(app('steam')->getSafePreviousUrl());
|
||||
}
|
||||
|
@@ -389,4 +389,21 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
|
||||
return TransactionJournalLink::whereDestinationId($two->id)->whereSourceId($one->id)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function switchLinkById(int $linkId): bool
|
||||
{
|
||||
/** @var TransactionJournalLink $link */
|
||||
$link = TransactionJournalLink::find($linkId);
|
||||
if (null !== $link) {
|
||||
|
||||
if ($link->source->user->id === $this->user->id) {
|
||||
$this->switchLink($link);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@@ -154,6 +154,13 @@ interface LinkTypeRepositoryInterface
|
||||
*/
|
||||
public function switchLink(TransactionJournalLink $link): bool;
|
||||
|
||||
/**
|
||||
* @param int $linkId
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function switchLinkById(int $linkId): bool;
|
||||
|
||||
/**
|
||||
* @param LinkType $linkType
|
||||
* @param array $data
|
||||
|
Reference in New Issue
Block a user