M
M
Maxim Shevchenko2019-08-27 09:26:04
Laravel
Maxim Shevchenko, 2019-08-27 09:26:04

How to make it so that the route without a parameter would not display on the 404 page?

I'm still trying to figure out the routing system.
There are two such routes

Route::resource('portfolio','Portfolio\PortfoliosController',['only' =>['index','show']]);
Route::get('portfolio/cat/{alias}',['uses' => 'Portfolio\[email protected]', 'as'=>'portfolioCat'])->where('alias','[\w-]+');

The first lists all the items on the page, the second only lists those that belong to a particular category.
These two requests are handled by the same controller and the same action.
The problem is that when we access http://local.domain/portfolio/cat (without parameters), we get a 404 page. I tried to insert middleware into the request, but, as I understand it, such a route ( http://local.domain/portfolio/cat ) simply does not exist.
The question is how do you deal with situations like this? Or just create routes somehow to a friend. Share your experience who cares

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question