0

I have 2 questions about Service Container.

1: Is it possible in the process of service container that i have a route , and before that route is resolved to a controller, based on a slug the route is directed to two different controllers. what i want to achieve is something like method overloading(route overloading) but the slug is of the same type in both cases.

2: is it possible in service container to map a route to a controller based on a boolean val attached to the route, if the val is 1 go to this controller and vice versa.

e.g

Route::get('/test/{slug}','controller1@somemethod')->(boolean_val=0)
Route::get('/test/{slug}','controller2@somemethod')->(boolean_val=1) 

Any help will be appreciated, and if anybody has any other solution to this problem other than middleware, do share.

Thank You

  • Did you also delete your last question that could be edited? Whats the reason for not using middlewares? – Kyslik Jun 22 '17 at 11:18
  • the reason i don't want to use middleware is i don't want to do any heavy task in middleware, and apart from that i want to learn the inner working of the service container, and want to see if this task is achievable by other means. – Muhammad Imran Jun 22 '17 at 11:28
  • I don't believe that's really the purpose of the service container. The service container is meant for providing data throughout the application and binding things to classes when they are instantiated. Middleware is suited for this use case, in my opinion. – Mark Jun 22 '17 at 12:52

0 Answers0