Posts Learn Components Snippets Categories Tags About
/

Laravel Check if Route Exists

Get to know how to check if route exists in Laravel and perform action based on the route availability.

Created on Aug 10, 2021

63 views

To check if the route exists in Laravel, you can make use of the "Route::has('route.name')" method. By checking if route exists using this method, you will be able to perform certain logic that works like below.
@if (Route::has('password.request'))
    <a class="text-sm text-gray-800 dark:text-gray-400 hover:text-blue-500 dark:hover:text-blue-500" href="{{ route('password.request') }}">
        {{ __('Forgot your password?') }}
    </a>
@endif

To get the inverse you can use the exclamation mark to reverse the value.
@if (! Route::has('password.request'))
    // your code here
@endif

Snippets by

PostSrc poster

PostSrc

Full stack developer mainly focusing on the front end side of the web. The main author of PostSrc and loves writing tutorial and guides online.

Load comments for Laravel Check if Route Exists

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your project.

View Components

Other Code Snippets

More