-
-
Notifications
You must be signed in to change notification settings - Fork 14
fixing the route_parameter value null bug #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…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
if ($this->type === 'link') { | ||
return $this->url ?: '#'; | ||
} |
There was a problem hiding this comment.
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.
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 '#'; | ||
} | ||
} | ||
|
There was a problem hiding this comment.
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.
Thanks for the PR; I really appreciate it. Can you fix the 2 requested changes? |
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