Posts Learn Components Snippets Categories Tags Tools 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

5104 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

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

Load comments for Laravel Check if Route Exists

)