cep-api/app/Http/Controllers/CepController.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)
    {
        $this->validate($request, [
            'cep'         => 'required',
            'logradouro'  => 'required',
            'complemento' => 'nullable',
            'bairro'      => 'required',
            'cidade'      => 'required',
            'uf'          => 'required',
        ]);
        $cep = Cep::findorFail($id);
        $cep->cep = $request->input('cep');
        $cep->logradouro = $request->input('logradouro');
        $cep->complemento = $request->input('complemento');
        $cep->bairro = $request->input('bairro');
        $cep->cidade = $request->input('cidade');
        $cep->uf = $request->input('uf');
        $cep->save();
        return $cep;
    }
public function update ( Request $ request , $ id ) { $ this -> validate ( $ request , [ 'cep' => 'required' , 'logradouro' => 'required' , 'complemento' => 'nullable' , 'bairro' => 'required' , 'cidade' => 'required' , 'uf' => 'required' , ] ) ; $ cep = Cep :: findorFail ( $ id ) ; $ cep -> cep = $ request -> input ( 'cep' ) ; $ cep -> logradouro = $ request -> input ( 'logradouro' ) ; $ cep -> complemento = $ request -> input ( 'complemento' ) ; $ cep -> bairro = $ request -> input ( 'bairro' ) ; $ cep -> cidade = $ request -> input ( 'cidade' ) ; $ cep -> uf = $ request -> input ( 'uf' ) ; $ cep -> save ( ) ; return $ cep ; }
Update the specified resource in storage.
Update the specified resource in storage .