Skip to content

Commit

Permalink
fix: [bug] Refonte de l'ordre des routes
Browse files Browse the repository at this point in the history
la route `/{resources}/new` pointait directement vers `{resouces}::show()` car le flag `{resources}/(:id)` venait avant `{resources}/new` et on avait donc l'impression que `new` correspondait a un ID
  • Loading branch information
dimtrovich committed Jan 25, 2024
1 parent 88b8ff1 commit 27a594f
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/Router/RouteCollection.php
Expand Up @@ -970,27 +970,11 @@ public function presenter(string $name, array $options = []): self
'as' => $routeName . '.index',
]);
}
if (in_array('show', $methods, true)) {
$this->get($name . '/show/' . $id, $newName . '::show/$1', $options + [
'as' => $routeName . '.view',
]);
$this->get($name . '/' . $id, $newName . '::show/$1', $options + [
'as' => $routeName . '.show',
]);
}
if (in_array('new', $methods, true)) {
$this->get($name . '/new', $newName . '::new', $options + [
'as' => $routeName . '.new',
]);
}
if (in_array('create', $methods, true)) {
$this->post($name . '/create', $newName . '::create', $options + [
'as' => $routeName . '.create',
]);
$this->post($name, $newName . '::create', $options + [
'as' => $routeName . '.store',
]);
}
if (in_array('edit', $methods, true)) {
$this->get($name . '/edit/' . $id, $newName . '::edit/$1', $options + [
'as' => $routeName . '.edit',
Expand All @@ -1011,6 +995,22 @@ public function presenter(string $name, array $options = []): self
'as' => $routeName . '.delete',
]);
}
if (in_array('create', $methods, true)) {
$this->post($name . '/create', $newName . '::create', $options + [
'as' => $routeName . '.create',
]);
$this->post($name, $newName . '::create', $options + [
'as' => $routeName . '.store',
]);
}
if (in_array('show', $methods, true)) {
$this->get($name . '/show/' . $id, $newName . '::show/$1', $options + [
'as' => $routeName . '.view',
]);
$this->get($name . '/' . $id, $newName . '::show/$1', $options + [
'as' => $routeName . '.show',
]);
}

return $this;
}
Expand Down

0 comments on commit 27a594f

Please sign in to comment.