Hello @dushyant674
I see that you have an optional parameter in the route (the slug) but that it isn't optional in the controller action.
You can change that with adding a default value, example:
public function products($slug = '')
{
dd($slug);
}
But to be honest I personal should split the route without a slug to another function then the url with a slug. And use the crud route names, see the documentation on https://laravel.com/docs/11.x/controllers#actions-handled-by-resource-controllers
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community