Skip to content

Conversation

Amrit-Acharya1
Copy link

fixing the route_parameter value null bug , In route parameter for url type = route, if key is set and value was null then , code was breaking , so i fixed it, now if key is set but value is null, then # will be route

…r key and value , if key is set and value was then , code was breaking , so i fixed that, now if key is set but value is null, then # will be route
Comment on lines +94 to +96
if ($this->type === 'link') {
return $this->url ?: '#';
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If type is link, then it should use $this->resolveUrl() to resolve the URL.

Comment on lines +98 to +120
if ($this->type === 'route' && $this->route) {
try {
$parameters = is_array($this->route_parameters) ? $this->route_parameters : [];
$route = app('router')->getRoutes()->getByName($this->route);
if ($route) {
$uri = $route->uri();
preg_match_all('/\{(\w+?)\}/', $uri, $matches);
$requiredParameters = $matches[1];
foreach ($requiredParameters as $param) {
if (!isset($parameters[$param]) || is_null($parameters[$param]) || trim($parameters[$param]) === '') {

return '#';
}
}
return route($this->route, $parameters);
}
return '#';
} catch (\Illuminate\Routing\Exceptions\UrlGenerationException $e) {

return '#';
}
}

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure if this is the most viable solution for the problem. I believe there might be a simpler approach.

@Biostate
Copy link
Owner

Thanks for the PR; I really appreciate it. Can you fix the 2 requested changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants