I have this defined in my routes.php file
Route::post(\'gestionAdministrador\', array(\'as\' => \'Loguearse\', \'uses\' => \'AdministradorController@Login
You have following routes declared:
Route::post('gestionAdministrador', array('as' => 'Loguearse', 'uses' => 'AdministradorController@Login'));
Route::post('gestionAdministrador', array('as' => 'RegistrarAdministrador', 'uses' => 'AdministradorController@RegistrarAdministrador'));
Both of these used post
method and this is post
method:
public function post($uri, $action)
{
return $this->addRoute('POST', $uri, $action);
}
It calls addRoute
and here it is:
protected function addRoute($methods, $uri, $action)
{
return $this->routes->add($this->createRoute($methods, $uri, $action));
}
Here $this->routes->add
means Illuminate\Routing\RouteCollection::add()
and the add()
method calls addToCollections()
and it is as follows:
protected function addToCollections($route)
{
foreach ($route->methods() as $method)
{
$this->routes[$method][$route->domain().$route->getUri()] = $route;
}
$this->allRoutes[$method.$route->domain().$route->getUri()] = $route;
}
The $routes
is an array (protected $routes = array();
) and it's obvious that routes are grouped by methods
(GET/POST etc) and in each method only one unique URL
could be available because it's something like this:
$routes['post']['someUrl'] = 'a route';
$routes['post']['someUrl'] = 'a route';
So, in your case, the last one is replacing the first one and in this case you may use different methods to declare two routes using same URL
so it would be in different array, something like this:
$routes['post']['someUrl'] = 'a route';
$routes['put']['someUrl'] = 'a route'; // Route::put(...)
There must be a way to go to the same url from two different forms
Yes, there is a way and it's simply that you have to use the same route as the action of your form and therefore, you don't need to declare it twice.