Registered route in web.php

Route::get('/posts/{cat}','IndexController@index'); 

If you just specify '/ posts' in the url, meaning that $ cat is empty, the error page returns that the page was not found. What could be the problem?

1 answer 1

That's right to specify an optional parameter in the route.

 Route::get('/posts/{cat?}','IndexController@index');