/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit(Condition $condition, Category $category, $id) { try { $product = Product::with(['price', 'price.stantion', 'price.stantion.train_road'])->where('id', $id)->first(); } catch (ModelNotFoundException $e) { abort(404); } if (!$product) { abort(404); } $VAT_rate = Product::getAllVAT_rate(); $conditions = $condition->all(); $categories = $category->all(); $prices = $product->price; $pricesArr = []; foreach ($prices as $price) { $pricesArr[$price->stantion[0]->train_road->id][$price->stantion[0]->train_road->tr_name][] = ['stantion_name' => $price->stantion[0]->stantion_name, 'stantion_id' => $price->stantion[0]->id, 'price' => $price->price, 'amount' => $price->amount, 'nds' => $price->nds]; } unset($prices); return view('products.edit', ['product' => $product, 'conditions' => $conditions, 'conditionID' => $product->condition_id, 'categories' => $categories, 'categoryID' => $product->category_id, 'id' => $product->id, 'prices' => $pricesArr, 'VAT_rate' => $VAT_rate]); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $conds = Condition::all(); return view('conditions.index', ['conds' => $conds]); }
public function index() { // show all $records = Condition::all(); return $records; }