app/Http/Controllers/Compras_OtController.php
/**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
Update the specified resource in storage.
Update the specified resource in storage .
public function update(Request $request, $id)
    {
      $data= $request->all();
          $compras=$data['compras'][0];
        $vl=$this->validatorCrearCompra($compras);
        if ($vl->fails())
        {
           return response([
              'status' => Response::HTTP_BAD_REQUEST,
              'response_time' => microtime(true) - LARAVEL_START,
              'msg' => 'Error al Editar la Compra',
              'error' => 'ERR_01',
               'request' => $request->all(),
              'obj' =>$vl->errors()
              ],Response::HTTP_BAD_REQUEST);
        }else
        {
           try
           {
                 $compra =Compras_Ot::findOrFail($id);
                 $compra->fill($compras);
                 $compra->save();
              return response([
                 'status' => Response::HTTP_OK,
                 'response_time' => microtime(true) - LARAVEL_START,
                 'msg' => 'Compra Editada Correactamente !!',
                 'obj' =>  $compra
                 ],Response::HTTP_OK);
           }catch(Exception $e){
              return response([
                 'status' => Response::HTTP_BAD_REQUEST,
                 'response_time' => microtime(true) - LARAVEL_START,
                 'error_creacion' => 'fallo_en_la_creacion',
                 'consola' =>$e->getMessage(),
                 'request' => $request->all()
                 ],Response::HTTP_BAD_REQUEST);
           }
        }
    }
public function update ( Request $ request , $ id ) { $ data = $ request -> all ( ) ; $ compras = $ data [ 'compras' ] [ 0 ] ; $ vl = $ this -> validatorCrearCompra ( $ compras ) ; if ( $ vl -> fails ( ) ) { return response ( [ 'status' => Response :: HTTP_BAD_REQUEST , 'response_time' => microtime ( true ) - LARAVEL_START , 'msg' => 'Error al Editar la Compra' , 'error' => 'ERR_01' , 'request' => $ request -> all ( ) , 'obj' => $ vl -> errors ( ) ] , Response :: HTTP_BAD_REQUEST ) ; } else { try { $ compra = Compras_Ot :: findOrFail ( $ id ) ; $ compra -> fill ( $ compras ) ; $ compra -> save ( ) ; return response ( [ 'status' => Response :: HTTP_OK , 'response_time' => microtime ( true ) - LARAVEL_START , 'msg' => 'Compra Editada Correactamente !!' , 'obj' => $ compra ] , Response :: HTTP_OK ) ; } catch ( Exception $ e ) { return response ( [ 'status' => Response :: HTTP_BAD_REQUEST , 'response_time' => microtime ( true ) - LARAVEL_START , 'error_creacion' => 'fallo_en_la_creacion' , 'consola' => $ e -> getMessage ( ) , 'request' => $ request -> all ( ) ] , Response :: HTTP_BAD_REQUEST ) ; } } }
Update the specified resource in storage.
Update the specified resource in storage .
//Validaciòn de las entradas por el metodo POST //Mensaje a mostrar