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:
@@ -41,20 +41,29 @@ class BudgetList implements BinderInterface
|
||||
public static function routeBinder(string $value, Route $route): Collection
|
||||
{
|
||||
if (auth()->check()) {
|
||||
$ids = explode(',', $value);
|
||||
/** @var \Illuminate\Support\Collection $object */
|
||||
$object = Budget::where('active', 1)
|
||||
->whereIn('id', $ids)
|
||||
->where('user_id', auth()->user()->id)
|
||||
->get();
|
||||
|
||||
// add empty budget if applicable.
|
||||
if (in_array('0', $ids)) {
|
||||
$object->push(new Budget);
|
||||
$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()->budgets()
|
||||
->where('active', 1)
|
||||
->whereIn('id', $list)
|
||||
->get();
|
||||
|
||||
// add empty budget if applicable.
|
||||
if (in_array(0, $list)) {
|
||||
$collection->push(new Budget);
|
||||
}
|
||||
|
||||
if ($collection->count() > 0) {
|
||||
return $collection;
|
||||
}
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
|
Reference in New Issue
Block a user