Oh that one is now working when I used this :
* public function makeAdmin($userId){
$user = User::where('id',$userId)->first();*
$old_role = $user->role;
$name = $user->name;
$user->update([
'role'=>'admin'
]);
session()->flash("success","Now {$name} role {$old_role} is updated to {$user['role']}");
return redirect(route('users.index'));
}
But I am still confused why the route binding User $user
not worked ?
@ Jason Weiss , Yes I used that . Otherwise it would give me a error . But it don't give me any error . it works good but the data is not updating
The route parameter and the controller method parameter should match.
Change userId to user in the following route:
Route::post('users/{**userId**}/make-admin','UsersController@makeAdmin')->name('users.make-admin');
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community