为什么不能在laravel中更新密码和密码确认?

时间:2018-08-02 07:22:06

标签: mysql laravel-5

我正在使用laravel 5.6并打算更新用户表。这样,我还需要更新密码列。在我的编辑表单中

<div class="form-group">
                <label for="name">Name</label>
                <input type="text" class="form-control" id="name" name="name" value="{{$user->name}}" >
            </div>

            <div class="form-group">
            <label for="exampleFormControlSelect1">User Level</label>
            <select class="form-control" id="uservalue" name="uservalue" value="{{$user->uservalue}}">
            <option>0</option>
            <option>2</option>
            <option>1</option>

            </select>
            </div> 
<div class="form-group">
                <label for="email">Email</label>
                <input type="text" class="form-control" id="email" name="email" value="{{$user->email}}">
            </div>

            <div class="form-group">
                <label for="password">Password</label>

                <input id="password" type="password" class="form-control" name="password">

            </div>

            <div class="form-group">
                <label for="password-confirm">Confirm Password</label>

               <input id="password-confirm" type="password" class="form-control" name="password_confirmation">

            </div>

我的userController是

public function update(Request $request, $id)
    {
        $this->validate($request,[
         'name' => 'required|max:255',
         'uservalue' => 'required',
         'email' => 'required|email|unique:users',

        ]);
        $user = User::findOrFail($id);
        $user->name = $request->name;
        $user->uservalue = $request->uservalue;
        $user->email = $request->email;
        $user->password = bcrypt($request->input('password'));
        $user->save();
        return view('users.show')->withUser($user);
    }

但是当我输入新密码时我的密码输入不起作用,这不是将数据保存到表中,也不是对确认密码进行验证。我该如何解决这个问题?

0 个答案:

没有答案