Reputation: 21
Im newbie in laravel and php, im using laravel 4.0 I want to show the user profile that is already logged in via the menu view profile but there is always an error
This is my Layout.blade.php
<li class="dropdown {{Request::is('users*') ? 'active' : ''}}">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Profile <b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<a href="{{ action('UserController@show', array($user->id)) }}">{{Sentry::getUser()->email}}</a>
</li>
</ul>
This my UserController.php
public function show($id)
{
$user = $this->user->byId($id);
if ($user == null || !is_numeric($id)) {
// @codeCoverageIgnoreStart
return \App::abort(404);
// @codeCoverageIgnoreEnd
}
return View::make('users.show')
->with('user', $user);
}
Upvotes: 2
Views: 80
Reputation: 2126
Correct me if I wrong.
Just wondering Layout.blade.php file. Your controller file return to users.show layout file. I guess that your folder structure look like
/users/show.blade.php
Are your return to show.blade.php or layout.blade.php?
Upvotes: 0
Reputation: 704
Check this line of your code
$user =$this->user->byId($id);
I think it should be changed to User::byId
. and also there need to have a function defined as byId
in the User model. or else use eloquent functions such as User::find($id)
Try replacing above line with below code line
$user=User::find($id);
Upvotes: 1