I would probably accept the id into the single controller, then dispatch a class to handle the request type (strategy pattern I think)
Nov 11, 2021
4
Level 1
Dynamic controller based on input param
Hello,
I have route like this $router->post('something/{id}', ['uses' => 'MyController@process']);
I want that controller name is different based on {id}param. With id I look in db and read some data and based on data type I want to run corresponding controller.
I guess I need to use Middleware where I can do this database operation and define type of controller to be executed but how to execute proper controller then ?
All I see in Middleware examples is that either you do redirect to some URL or return $next($request);
Please or to participate in this conversation.