protected function replaceRouteParameters($path, array &$parameters)
{
$path = $this->replaceNamedParameters($path, $parameters);
$path = preg_replace_callback('/\\{.*?\\}/', function ($match) use(&$parameters) {
return empty($parameters) && !Str::endsWith($match[0], '?}') ? $match[0] : array_shift($parameters);
}, $path);
return trim(preg_replace('/\\{.*?\\?\\}/', '', $path), '/');
}