i'm not sure about the controller construct but you CAN send to the controller method. http://laravel.com/docs/5.1/routing#route-parameters
yes route parameters can send to the controller method, but I can't find a way that route parameters can send to the controller construct.
found a solution
[ laravel 5.1 ] ~ edited
Route::group(['prefix' => '{sites}', 'as' => 'sites.'], function () {
Route::get('/', [
'as' => 'index',
'uses' => 'SitesController@index'
])
->where('sites', '[0-9A-Za-z_.]+');
});
});
SitesController.php
public function __construct(Request $request)
{
print_r($request->sites);
}
hope this is useful for others
but then if it is a parameter, you can use $request without doing any "hack".. but maybe if you tell us what you are trying to do people can recommend a better approach?
I'm trying to get parameter {sites} from route and send to _construct controller, so I can check that parameter globally and set var global in that controller.
I change my code and use middleware.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community