Hello!
I there way to use one controller class but for different routes? I mean, one controller class but with different parameters in constructor.
I tryied to do something like that:
App::bind('cats_controller', function () {
return new AnimalController(App::make('CatRepository'));
});
App::bind('dogs_controller', function () {
return new AnimalController(App::make('DogRepository'));
});
# routes.php
Route:controller('cats', 'cats_controller');
Route:controller('dogs', 'dogs_controller');
But it didn't actually work.
There is, ofcourse a variant with inheritance, but is there way to make it without it?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community