コード例 #1
0
ファイル: ComprasController.php プロジェクト: iarmoa/gaia
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $data = $request->all();
     $compra = Compras::where('id', $id)->with('insumos')->first();
     //print_r($data); die();
     $compra->update($data);
     if (!empty($data['insumos'])) {
         foreach ($data['insumos'] as $i => $insumo) {
             \DB::table('compras_insumos')->where('id', $insumo['id'])->update(array('cantidad' => $insumo['cantidad'], 'precio' => $insumo['precio']));
         }
     }
     if (!empty($data['deleteinsumo'])) {
         foreach ($data['deleteinsumo'] as $insumo) {
             \DB::table('compras_insumos')->where('id', '=', $insumo)->delete();
         }
     }
     return redirect()->route('compras.show', $compra->id);
 }
コード例 #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $comprasinsumos = Compras::where('id', $id)->with('insumos')->first();
     return view('comprasinsumos.show', ['comprasinsumos' => $comprasinsumos]);
 }