If no route matched route::fallback in laravel
If no route matched route::fallback in laravel
In this article, we will see how to solve "If no route matched route::fallback in laravel".
Sometimes users request a web url or hit an API route which does not exist in our web route list then it returns a 404 error page. The route::fallback method helps you to return the message if web route does not exists in web.php or api.php-
Return message if no route matched in laravel using Route::fallback
Route::fallback(function() { return 'Route does not exist !'; });
Use this code snippet at the bottom of routes\api.php and routes\web.php file to return the message on hit API request or web url in laravel.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
Don't forget to share this article! Help us spread the word by clicking the share button below.
We appreciate your support and are committed to providing you valuable and informative content.
We are thankful for your never ending support.
Random Code Snippet Queries: Laravel
- Create record with unique slug in laravel
- Get last week data in Laravel
- Fatal error: Uncaught Error: Class "Illuminate\Foundation\Application" not found
- Command to create MySQL Docker image and access the MySQL command-line interface (CLI) within a running Docker container
- Order by multiple columns in Laravel
- How to return error message from controller to view in laravel
- How to insert dynamic values to additional column with pivot column in pivot table on multiple records
- How to validate URL with https using regex in laravel
- Always load the relationship data with eager loading in Laravel
- RuntimeException You must enable the openssl extension in your php.ini to load information from https://repo.packagist.org
- How to pass query string with pagination in laravel
- Class 'App\Rules\Hash' not found in Laravel
- Call to undefined function Illuminate\Encryption\openssl_cipher_iv_length()
- SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint
- Call to a member function getRelationExistenceQuery() on array in Laravel
- Print query in laravel
- Call to a member function pluck() on null
- Update last created record in Laravel
- How to avoid duplicate entries in pivot table in Laravel
- Delete all related comments on deleting a post in Laravel
- Route group with URI prefix using middleware and route name prefixes
- SQLSTATE[42S02]: Base table or view not found: 1146 Table 'laravel8.projects' doesn't exist
- How to print form data in laravel
- How to check records exist in loaded relationship in Laravel blade view
- Get the products list ordered by a user