Skip to content

Commit

Permalink
add default parameters to route (fixes #12185)
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasZ committed Feb 19, 2016
1 parent a280ddb commit 33c16b0
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/Illuminate/Routing/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ public function bindParameters(Request $request)
);
}

return $this->parameters = $this->replaceDefaults($params);
return $this->parameters = $this->fillDefaults($this->replaceDefaults($params));
}

/**
Expand Down Expand Up @@ -615,6 +615,23 @@ protected function replaceDefaults(array $parameters)
return $parameters;
}

/**
* Fill missing parameters with their defaults.
*
* @param array $parameters
* @return array
*/
protected function fillDefaults(array $parameters)
{
foreach ($this->defaults as $key => $value) {
if (! isset($parameters[$key])) {
$parameters[$key] = $value;
}
}

return $parameters;
}

/**
* Parse the route action into a standard array.
*
Expand Down

0 comments on commit 33c16b0

Please sign in to comment.