I started to learn Laravel a couple of days ago. Right now I have a problem with a variable in my controller, I always get this error: "Undefined variable: server_id".
My route file looks like this:
Route::get('servers/{server_id}','ServersController@show');
And the action method in the related controller:
public function show($server_id)
{
$details = Server::with(array('details' => function($query)
{
$query->where('server_id', '=', $server_id);
}))->get();
return View::make('servers.show')->with('details', $details);
}
I can use the var. $server_id in the function and also pass it to the view. But i can't use it in the where clause for the database query.
I hope someone could explain me what the problem is and how to solve this.