php - Laravel Argument 1 passed string given -


so been 2 hours , can't still app work. getting error exception argument 1 passed app\http\controllers\programcontroller::index() must instance of app\user, string given. here route:

$app->bind('user', function($value, $route) {     return user::findorfail($value); });  $app->get('program/profile/{user}', 'app\http\controllers\programcontroller@index'); 

and in controller:

public function index(user $user) {     return view('auth.welcome', compact('user'));  } 

whenever run http://localhost:8000/program/profile/username, error. thoughts?

try:

public function index($username) {     $user = user::where('username', '=', $username)->first();      return view('auth.welcome', compact('user'));  } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -