I have the following 2 routes:
Route::get('/{category}/{slug?}', [CategoryController::class, 'index'])->name('category.index')->where('slug', 'trending|subtitled|feature');
This route
Route::get('/cookies-policy', [PageController::class, 'cookiesPolicy'])->name('cookiesPolicy');
When i try to access the second route, the first route controller is accessed instead.
How do i add a condition to the first route, that if the first segment isn't trending
,subtitled
or feature
then ignore? I thought i accomplished this with: ->where('slug', 'trending|subtitled|feature')
CodePudding user response:
You would need to adjust your where
to be assigning the pattern to the category
route parameter not the slug
parameter:
->where('category', ...);