jeudi 2 août 2018

why not working password and password confirmation update in laravel?

I am working with laravel 5.6 and going to update users table. in this way I need update password columns also. in my edit form

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

            <div class="form-group">
            <label for="exampleFormControlSelect1">User Level</label>
            <select class="form-control" id="uservalue" name="uservalue" value="">
            <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="">
            </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>

my userController is,

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);
    }

but my password input is not working when I enter new password it is not save data to table and not validation work to confirmation password. how can I fix this problem?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire