app/Http/Controllers/MotoController.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)
    {
        $json = $request->input('moto',null);
        $param_array= json_decode($json, true);
        $validate = \Validator::make($param_array,[
            'modelo' => 'required'
        ]);
        $moto = new Moto();
        $moto->modelo=($param_array['modelo']);
        $moto->chasis = ($param_array['chasis']);
        $moto->motor=($param_array['motor']);
        $moto->cilindraje=($param_array['cilindraje']);
        $moto->ref=($param_array['ref']);
        $moto->cpn=($param_array['cpn']);
        $moto->cn1=($param_array['cn1']);
        $moto->cn2=($param_array['cn2']);
        $moto->anio=($param_array['anio']);
        $moto->color1=($param_array['color1']);
        $moto->color2=($param_array['color2']);
        $moto->idproceso=($param_array['idproceso']);
        if($moto->save()){
            $respuesta = [
                'status' => "correcto",
                'moto' => $moto,
                'mensaje'=> 'Registro ingresado correctamente'
            ];
        }else{
            $respuesta = [
                'status' => "error",
                'mensaje'=> 'Error al guardar registro'
            ];
        }
        return \response()->json($respuesta,200);
    }
public function store ( Request $ request ) { $ json = $ request -> input ( 'moto' , null ) ; $ param_array = json_decode ( $ json , true ) ; $ validate = \ Validator :: make ( $ param_array , [ 'modelo' => 'required' ] ) ; $ moto = new Moto ( ) ; $ moto -> modelo = ( $ param_array [ 'modelo' ] ) ; $ moto -> chasis = ( $ param_array [ 'chasis' ] ) ; $ moto -> motor = ( $ param_array [ 'motor' ] ) ; $ moto -> cilindraje = ( $ param_array [ 'cilindraje' ] ) ; $ moto -> ref = ( $ param_array [ 'ref' ] ) ; $ moto -> cpn = ( $ param_array [ 'cpn' ] ) ; $ moto -> cn1 = ( $ param_array [ 'cn1' ] ) ; $ moto -> cn2 = ( $ param_array [ 'cn2' ] ) ; $ moto -> anio = ( $ param_array [ 'anio' ] ) ; $ moto -> color1 = ( $ param_array [ 'color1' ] ) ; $ moto -> color2 = ( $ param_array [ 'color2' ] ) ; $ moto -> idproceso = ( $ param_array [ 'idproceso' ] ) ; if ( $ moto -> save ( ) ) { $ respuesta = [ 'status' => " correcto " , 'moto' => $ moto , 'mensaje' => 'Registro ingresado correctamente' ] ; } else { $ respuesta = [ 'status' => " error " , 'mensaje' => 'Error al guardar registro' ] ; } return \ response ( ) -> json ( $ respuesta , 200 ) ; }
Store a newly created resource in storage.
Store a newly created resource in storage .