mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Expand binder test.
This commit is contained in:
@@ -22,7 +22,6 @@ declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Support\Binder;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Collection;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
@@ -41,14 +40,24 @@ class JournalList implements BinderInterface
|
||||
public static function routeBinder(string $value, Route $route): Collection
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$ids = explode(',', $value);
|
||||
/** @var \Illuminate\Support\Collection $object */
|
||||
$object = TransactionJournal::whereIn('transaction_journals.id', $ids)
|
||||
->where('transaction_journals.user_id', auth()->user()->id)
|
||||
->get(['transaction_journals.*']);
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
foreach ($incoming as $entry) {
|
||||
$list[] = intval($entry);
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (count($list) === 0) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
if ($object->count() > 0) {
|
||||
return $object;
|
||||
/** @var \Illuminate\Support\Collection $collection */
|
||||
$collection = auth()->user()->transactionJournals()
|
||||
->whereIn('transaction_journals.id', $list)
|
||||
->where('transaction_journals.completed', 1)
|
||||
->get(['transaction_journals.*']);
|
||||
|
||||
if ($collection->count() > 0) {
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
|
Reference in New Issue
Block a user