The URL matched format for a URL like "user/manage/id/1/role/admin" is:
controler: user
action: manage
params: [ 'id' => 1, 'role' => 'admin' ]
| <?php | |
| Route::match( | |
| ['get', 'post'], | |
| '{controller}/{action?}/{params?}', | |
| function ($controller, $action = 'index', $params = '') { | |
| $params = explode('/', $params); | |
| $methodParams = []; | |
| foreach ($params as $key => $param) { | |
| if ($key % 2) | |
| $methodParams[$params[$key - 1]] = $param; | |
| } | |
| $app = app(); | |
| $controller = $app->make("\App\Http\Controllers\\" . ucwords($controller) . 'Controller'); | |
| return $controller->callAction($action, $methodParams); | |
| } | |
| ) |