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


To check if the route exists in Laravel, you can make use of the "Route::has('')" 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?') }}

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

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


PostSrc Code Components

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

View Components

Sponsors 👑

+ Add Yours