app/Http/Controllers/home/AddressController.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)
    {
        $req = $request->except(['_token']);
        $has = $request->has(['name','phone','address','postcode']);
        if($has){
            $address = Address::find($id);
            $address -> name = $req['name'];
            $address -> phone = $req['phone'];
            $address -> address = $req['address'];
            $address -> postcode = $req['postcode'];
            $address -> label = $req['label'];
            $res = $address->save();
            if($res){
                return redirect('home/address/index')-> with('success','修改成功');
            }else{
                return back()->with('error','修改失败');
            }
        }else{
            return back()->with('error','请补全所有内容');
        }
    }
public function update ( Request $ request , $ id ) { $ req = $ request -> except ( [ '_token' ] ) ; $ has = $ request -> has ( [ 'name' , 'phone' , 'address' , 'postcode' ] ) ; if ( $ has ) { $ address = Address :: find ( $ id ) ; $ address -> name = $ req [ 'name' ] ; $ address -> phone = $ req [ 'phone' ] ; $ address -> address = $ req [ 'address' ] ; $ address -> postcode = $ req [ 'postcode' ] ; $ address -> label = $ req [ 'label' ] ; $ res = $ address -> save ( ) ; if ( $ res ) { return redirect ( 'home/address/index' ) -> with ( 'success' , '修改成功'); } else { return back ( ) -> with ( 'error' , '修改失败'); } } else { return back ( ) -> with ( 'error' , '请补全所有内容'); } }
Update the specified resource in storage.
Update the specified resource in storage .