/** * Show the form for editing the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function edit($id) { $product = Product::find($id); $providers = Provider::all(); $productTypes = ProductType::all(); return view('product.edit', compact('product', 'productTypes', 'providers')); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { $productType = ProductType::find($id); $products = DB::table('products')->select('id')->where('product_type_id', '=', $productType->id)->get(); foreach ($products as $product) { Product::destroy($product->id); } ProductType::destroy($id); Session::flash('message', 'Tipo de producto Eliminado Correctamente'); return Redirect::to('/productType'); }