has('user_id')) { return redirect($router->route('show-register-form')); } $parameters = $router->current()->parameters(); $item = Item::find((int) $parameters['item']); if (!$item) { return redirect($router->route('show-items')); } $stock = Stock::where('item_id', $item->id)->all(); $stock = array_filter($stock, fn($row) => $row->quantity > 0); return view('items/withdraw', [ 'item' => $item, 'stock' => $stock, 'withdrawAction' => $router->route('withdraw-stock', ['item' => $item->id]), 'csrf' => csrf(), ]); } }