Reputation: 3
I'm working on Laravel framework so I just making different examples to learn.I wrote this code block:
show.blade.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>Hello,{{ $user->username }}</h1>
</body>
</html>
route.php
Route::get('users/{username}',function($username){
$user = User::whereUsername($username)->first();
return View::make('users.show',['user=>$user']);
});
I m calling my users with this url :http://localhost:8888/l4/public/users/xxx
Error:
ErrorException
Undefined variable: user (View: /Applications/MAMP/htdocs/l4/app/views/users/show.blade.php)
Upvotes: 0
Views: 396
Reputation: 87719
Looks like you have a bug around. :)
Route::get('users/{username}',function($username){
$user = User::whereUsername($username)->first();
return View::make('users.show',['user' => $user]);
});
Upvotes: 1