. */ declare(strict_types=1); namespace FireflyIII\Support\Binder; use Illuminate\Routing\Route; use Illuminate\Support\Collection; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** * Class JournalList. */ class JournalList implements BinderInterface { /** * @param string $value * @param Route $route * * @return mixed */ public static function routeBinder(string $value, Route $route): Collection { if (auth()->check()) { $list = []; $incoming = explode(',', $value); foreach ($incoming as $entry) { $list[] = intval($entry); } $list = array_unique($list); if (count($list) === 0) { throw new NotFoundHttpException; // @codeCoverageIgnore } /** @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; } }