Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why route in web.php conflicts due to a parameter passing in laravel 8

I have route in web.php

Route::get('{cat}',[WebsiteController::class,'dbCategories'])->name('dbCategories');

{cat} is slug of the particular category whose products are to be shown.

I have issue with another route here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Route::get('blogs',[WebsiteController::class,'show_blogs_toWebsite'])->name('show_blogs_toWebsite');

When i hit this route it goes to first one. How can i differentiate these two.
Please help me. thanks.

>Solution :

  1. You can change first route url by adding a string before or after {cat} like
    Route::get(‘/category/{cat}’,[WebsiteController::class,’dbCategories’])->name(‘dbCategories’)

Also , if you will change the ordering of routes , It will be work fine

Note: run php artisan route:clear command before testing

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading