Reputation: 125
I want to update user password
This is my function:
public function modifiermdp(Request $request)
{
$userupdate = Auth::user();
$password = bcrypt($request['password']);
$userupdate->fill(['password' => $password])->save();
return Redirect::back()->with('message', 'تم التعديل بنجاح');
}
This is my route:
Route::prefix('/compte')->group(function() {
Route::get('/', 'CompteController@index');
Route::post('/changemdp', 'CompteController@modifiermdp');
});
And I'm using database driver in config/auth.php
'providers' => [
'enseignant' => [
'driver' => 'database',
'table' => 'enseignant',
],
],
I get this error
FatalErrorException in CompteController.php line 38: Call to undefined method Illuminate\Auth\GenericUser::fill()
Upvotes: 2
Views: 1557
Reputation: 11906
Since it's a database driver, you have to do it manually.
\DB::table('enseignant')
->where('id', $user->getAuthIdentifier())
->update(['password' => $password]);
Upvotes: 1