gpt4 book ai didi

php - Laravel 检查给定 url 的路由是否存在于路由中

转载 作者:行者123 更新时间:2023-12-04 03:12:38 28 4
gpt4 key购买 nike

通过提供 URL,我想知道是否有任何方法可以确定该 URL 是否存在于我的 Laravel 应用程序中(与想要检查外部 URL 的“How can I check if a URL exists via Laravel? ”相比)?

我试过这个,但它总是告诉我 URL 不匹配:

$routes = \Route::getRoutes();
$request = \Request::create('/exists');
try {
$routes->match($request);
// route exists
} catch (\Symfony\Component\HttpKernel\Exception\NotFoundHttpException $e){
// route doesn't exist
}

最佳答案

只需使用 if Route::has('example')

关于php - Laravel 检查给定 url 的路由是否存在于路由中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43780964/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com