Support the ongoing development of →
Database Eloquent Forms
Last updated 1 year ago.

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;
    	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 ?


Do you have use App\User; in the top of the file?


@ 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','[email protected]')->name('users.make-admin');


Sign in to participate in this thread!


Your banner here too?

Nymur Rahman nymur Joined 14 Nov 2018


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2023 - All rights reserved.