Laravel. How to get route from given URL. I know about this answer: https://stackoverflow.com/a/36476224/9696145
This way doesn't help me bacause if you set wrong URI my app for some reason return 404 view. I need to just return something like null
Laravel. How to get route from given URL. I know about this answer: https://stackoverflow.com/a/36476224/9696145
This way doesn't help me bacause if you set wrong URI my app for some reason return 404 view. I need to just return something like null
https://laracasts.com/discuss/channels/laravel/how-to-get-a-route-from-uri
try {
$url = 'url';
$route = app('router')->getRoutes()->match(app('request')->create($url))
} catch (NotFoundHttpException $e) {
$route = null;
}
In case of non-get routes:
$method = 'POST';
$url = 'url';
$route = app('router')->getRoutes()->match(app('request')->create($url , $method))