I am getting below error:
ErrorException (E_UNKNOWN) Undefined variable: id
below is my code, It is from "Controller"
public function show($id)
{
if(Auth::user()) {
$message = Message::where(function($query) {
$query->where('from_user', '=', Auth::user()->username)->where('id', '=', $id);
})->orWhere(function($query) {
$query->where('from_user', '=', Auth::user()->username)->where('id', '=', $id);
});
if($message == null) {
return Redirect::action('MessageController@index');
}
return View::make('view', ['message' => $message, 'active' => 'none']);
}
}
Update: My Route is : Route::get('/message/{id}', 'MessageController@show')->before('auth');
I could not understand, what i am messing with up, I have already passed $id
in function argument.