Skip to content

Check If Route Exists in Laravel

laravel check if route exists

Let’s look at how we can check if a route exists in a Laravel project.

 

We’re going to use the has() method from the Route facade.

Note that it tries to find the route by name.

If your API route doesn’t have a name it won’t be able to find it.

We can use the same logic in the Blade templates as well.

 

Happy coding 😊

 


Let me know what you think about this article in the comments section below.

If you find this article helpful, please share it with others and subscribe to the blog to support me, and receive a bi-monthly-ish e-mail notification on my latest articles.   
  

Comments

Tags: