I tried to pass variable in route with this, and it works:
Route::get('/path', array("as"=>"myname", function(){
$data = include app_path()."/views/myconfig.php";
return View::make('pageview',$data);
}));
As I need to use the data in most routes, I am thinking to move the $data
outside so that it looks cleaner.
$data = include app_path()."/views/myconfig.php";
Route::get('/path', array("as"=>"myname", function(){
return View::make('pageview',$data);
}));
Route::get('/path2', array("as"=>"myname2", function(){
return View::make('pageview2',$data);
}));
But this end up giving me error saying that Undefined variable: data
. Why is it moving it up become unreadable? What do you suggest a better way I can do it?
Thank you.