app/Http/Controllers/DivisasController.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->validatorCrearDivisa($request->all());
        if ($vl->fails())
        {
            return response([
                'status' => Response::HTTP_BAD_REQUEST,
                'response_time' => microtime(true) - LARAVEL_START,
                'msg' => 'Error en algunos campos',
                'error' => 'ERR_01',
                'obj' =>$vl->errors()
                ],Response::HTTP_BAD_REQUEST);
        }else
        {
                $divisa=new Divisa;
                $divisa->fill($request->all());
                try
                {
                 $divisa->save();
                 return response([
                    'status' => Response::HTTP_OK,
                    'response_time' => microtime(true) - LARAVEL_START,
                    'obj' => $divisa,
                    'msg' => 'Divisa creada',
                    ],Response::HTTP_OK);
             }catch(Exception $e){
                return response([
                    'status' => Response::HTTP_BAD_REQUEST,
                    'response_time' => microtime(true) - LARAVEL_START,
                    'error' => 'Fallo la creación de la divisa, comunicate con soporte',
                    'consola' =>$e->getMessage(),
                    'obj' => [],
                    'request' => $request->all()
                    ],Response::HTTP_BAD_REQUEST);
            }
        }
    }
public function store ( Request $ request ) { $ vl = $ this -> validatorCrearDivisa ( $ request -> all ( ) ) ; if ( $ vl -> fails ( ) ) { return response ( [ 'status' => Response :: HTTP_BAD_REQUEST , 'response_time' => microtime ( true ) - LARAVEL_START , 'msg' => 'Error en algunos campos' , 'error' => 'ERR_01' , 'obj' => $ vl -> errors ( ) ] , Response :: HTTP_BAD_REQUEST ) ; } else { $ divisa = new Divisa ; $ divisa -> fill ( $ request -> all ( ) ) ; try { $ divisa -> save ( ) ; return response ( [ 'status' => Response :: HTTP_OK , 'response_time' => microtime ( true ) - LARAVEL_START , 'obj' => $ divisa , 'msg' => 'Divisa creada' , ] , Response :: HTTP_OK ) ; } catch ( Exception $ e ) { return response ( [ 'status' => Response :: HTTP_BAD_REQUEST , 'response_time' => microtime ( true ) - LARAVEL_START , 'error' => 'Fallo la creación de la divisa, comunicate con soporte', 'consola' => $ e -> getMessage ( ) , 'obj' => [ ] , 'request' => $ request -> all ( ) ] , Response :: HTTP_BAD_REQUEST ) ; } } }
Store a newly created resource in storage.
Store a newly created resource in storage .
//Validaciòn de las entradas por el metodo POST