@marosmjartan Yes, you’re going about this the wrong way.
Place your category route last and then it won’t overwrite any other “root” routes.
// All of your other routes...
// Your category route, last
Route::get('{category:slug}', [CategoryController::class, 'show'])->name('category.show');
class CategoryController extends Controller
{
public function show(Category $category)
{
return view('category.show', [
'products' => $category->products(),
]);
}
}
I don’t know how you’re planning to have routes with set names when they’re coming from the database, either… Just route properly using a generic route name and the category slug:
@foreach($categories as $category)
<li>
<a href="{{ route('category.show', compact('category')) }}">
{{ $category->name }}
</a>
</li>
@endforeach