Skip to content

Commit

Permalink
Merge pull request #1693 from macellan/array_routers
Browse files Browse the repository at this point in the history
Add array route support
  • Loading branch information
specialtactics authored Jan 6, 2020
2 parents 17473fe + 3c5751b commit 05299b0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Routing/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ public function addRoute($methods, $uri, $action)
$action = ['uses' => $action, 'controller' => $action];
} elseif ($action instanceof Closure) {
$action = [$action];
} elseif (is_array($action)) {
// For this sort of syntax $api->post('login', [LoginController::class, 'login']);
if (is_string(Arr::first($action)) && class_exists(Arr::first($action)) && count($action) == 2) {
$action = implode('@', $action);
$action = ['uses' => $action, 'controller' => $action];
}
}

$action = $this->mergeLastGroupAttributes($action);
Expand Down

0 comments on commit 05299b0

Please sign in to comment.