app/Http/Controllers/home/AddressController.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,$id)
    {
        $req = $request->except(['_token']);
        $has = $request->has(['name','phone','address','postcode','s_xj']);
        if($has){
            $address = new Address;
            $address -> uid = $id;
            $address -> name = $req['name'];
            $address -> phone = $req['phone'];
            $address -> address = $req['s_sf'].$req['s_sq'].$req['s_xj'].$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 store ( Request $ request , $ id ) { $ req = $ request -> except ( [ '_token' ] ) ; $ has = $ request -> has ( [ 'name' , 'phone' , 'address' , 'postcode' , 's_xj' ] ) ; if ( $ has ) { $ address = new Address ; $ address -> uid = $ id ; $ address -> name = $ req [ 'name' ] ; $ address -> phone = $ req [ 'phone' ] ; $ address -> address = $ req [ 's_sf' ] . $ req [ 's_sq' ] . $ req [ 's_xj' ] . $ 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' , '请补全所有内容'); } }
Store a newly created resource in storage.
Store a newly created resource in storage .
// dump($res);