current()->parameters(); $location = Location::find((int) $parameters['location']); if (!$location) { return redirect($router->route('show-locations')); } $stock = Stock::where('location_id', $location->id)->all(); $stock = array_filter($stock, fn($row) => $row->quantity > 0); foreach ($stock as $row) { $row->itemRoute = $router->route('view-item', ['item' => $row->item_id]); } return view('locations/view', [ 'location' => $location, 'stock' => $stock, ]); } }