app/Http/Controllers/admin/UsersController.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)
    {
        $data = $request -> all();
        $users = Users::find($id);
        $users -> username = $data['username'];
        $users -> email = $data['email'];
        $res = $users -> save();
        $userdetails = Userdetails::where('uid',$id)->first();
        $userdetails -> nickname = $data['nickname'];
        $userdetails -> id_card = $data['id_card'];
        $userdetails -> phone = $data['phone'];
        $userdetails -> sex = $data['sex'];
        $userdetails -> addr = $data['addr'];
        $res2 = $userdetails -> save();
        if ($res || $res2 == true) {
            return redirect('/admin/users/index')-> with('success','修改成功');
        }else{
            return back()->with('error','修改失败');
        }
    }
public function update ( Request $ request , $ id ) { $ data = $ request -> all ( ) ; $ users = Users :: find ( $ id ) ; $ users -> username = $ data [ 'username' ] ; $ users -> email = $ data [ 'email' ] ; $ res = $ users -> save ( ) ; $ userdetails = Userdetails :: where ( 'uid' , $ id ) -> first ( ) ; $ userdetails -> nickname = $ data [ 'nickname' ] ; $ userdetails -> id_card = $ data [ 'id_card' ] ; $ userdetails -> phone = $ data [ 'phone' ] ; $ userdetails -> sex = $ data [ 'sex' ] ; $ userdetails -> addr = $ data [ 'addr' ] ; $ res2 = $ userdetails -> save ( ) ; if ( $ res || $ res2 == true ) { return redirect ( '/admin/users/index' ) -> with ( 'success' , '修改成功'); } else { return back ( ) -> with ( 'error' , '修改失败'); } }
Update the specified resource in storage.
Update the specified resource in storage .
//获取数据 //查找数据库数据,进行 修改 // dump($res); // dd($userdetails); // dd($res2);