Skip to content

Commit

Permalink
implements route defaults as additional parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
rizqyhi committed Jul 27, 2023
1 parent 2959839 commit 3b1bcbc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Illuminate/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,11 +455,16 @@ protected function matchToKeys(array $matches)
*/
protected function replaceDefaults(array $parameters)
{
foreach ($parameters as $key => &$value)
{
$value = isset($value) ? $value : array_get($this->defaults, $key);
foreach ($parameters as $key => $value) {
$parameters[$key] = $value ?? array_get($this->defaults, $key);
}

foreach ($this->defaults as $key => $value) {
if (! isset($parameters[$key])) {
$parameters[$key] = $value;
}
}

return $parameters;
}

Expand Down

0 comments on commit 3b1bcbc

Please sign in to comment.