/** * @param Route $newRoute * @throws RouterException */ public function add(Route $newRoute) { foreach ($this->routes as $route) { if ($newRoute->getMethod() == $route->getMethod() and $newRoute->getPath() == $route->getPath()) { throw new RouterException("Route {$route->getPath()} has already added to the route collection."); } } $this->routes[] = $newRoute; }
<?php use App\Routing\Route; return [Route::create('POST', '/getCustomers', 'CustomersController@getCustomers'), Route::create('GET', '/', 'CustomersController@index')];