I have a class that I inject into the controller along with the route parameter. Then I use setter to set the route parameter in the class.
routes
Route::get('path/of/url/with/{paramVar}', 'testController@testFunc)
controller
class testController
{
public function testFunc(MyClassInterface $class, $routeParamVar)
{
$class->setParam($routeParamVar);
...
service provider
public function register()
{
$this->bind('path\to\interface', 'path\to\concrete');
}
Instead, I would like to enter a route parameter into the constructor of the class that I inject into my controller. I know from this question that I need to use a laravel container.
I can enter other route parameters using Request::class
, but how can I enter a route route parameter?
I guess I will get something like this
class testController
{
public function testFunc(MyClassInterface $class)
{
...
source
share