コード例 #1
0
 /**
  * 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'));
 }
コード例 #2
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $provider = Provider::find($id);
     $products = DB::table('products')->select('id')->where('provider_id', '=', $provider->id)->get();
     foreach ($products as $product) {
         Product::destroy($product->id);
     }
     Provider::destroy($id);
     Session::flash('message', 'Proveedor eliminado correctamente');
     return Redirect::to('/provider');
 }