app/Http/Controllers/TiposCompraController.php
/**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
Store a newly created resource in storage.
Store a newly created resource in storage .
public function store(Request $request)
    {
        $vl=$this->validarCampos($request->all());
        if ($vl->fails()) {
             return response([
                'status' => Response::HTTP_BAD_REQUEST,
                'response_time' => microtime(true) - LARAVEL_START,
                'msg' => 'Error al crear el usuario',
                'error' => 'ERR_01',
                'obj' =>$vl->errors()
                ],Response::HTTP_BAD_REQUEST);        
         }else{
                $tipos_compra = new  Tipos_compra;
                $tipos_compra->fill($request->all());
            try {
                $tipos_compra->save();
                 return response([
                    'status' => Response::HTTP_OK,
                    'response_time' => microtime(true) - LARAVEL_START,
                    'tipos_compra' => $tipos_compra,
                    'msg' => 'Creado con éxito',
                    'request' => $request->all()
                ],Response::HTTP_OK);  
            } catch (Exception $e) {
                 return response([
                    'status' => Response::HTTP_BAD_REQUEST,
                    'response_time' => microtime(true) - LARAVEL_START,
                    'error' => 'Falla al ingresar datos',
                    'consola' =>$e,
                    'request' => $request->all()
                ],Response::HTTP_BAD_REQUEST);
            }
         }
    }
public function store ( Request $ request ) { $ vl = $ this -> validarCampos ( $ request -> all ( ) ) ; if ( $ vl -> fails ( ) ) { return response ( [ 'status' => Response :: HTTP_BAD_REQUEST , 'response_time' => microtime ( true ) - LARAVEL_START , 'msg' => 'Error al crear el usuario' , 'error' => 'ERR_01' , 'obj' => $ vl -> errors ( ) ] , Response :: HTTP_BAD_REQUEST ) ; } else { $ tipos_compra = new Tipos_compra ; $ tipos_compra -> fill ( $ request -> all ( ) ) ; try { $ tipos_compra -> save ( ) ; return response ( [ 'status' => Response :: HTTP_OK , 'response_time' => microtime ( true ) - LARAVEL_START , 'tipos_compra' => $ tipos_compra , 'msg' => 'Creado con éxito', 'request' => $ request -> all ( ) ] , Response :: HTTP_OK ) ; } catch ( Exception $ e ) { return response ( [ 'status' => Response :: HTTP_BAD_REQUEST , 'response_time' => microtime ( true ) - LARAVEL_START , 'error' => 'Falla al ingresar datos' , 'consola' => $ e , 'request' => $ request -> all ( ) ] , Response :: HTTP_BAD_REQUEST ) ; } } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//