Well first of all you cannot find a category by a category. You already have a category
public function show(Category $category)
{
return $category;
}
Is the route in api.php or web.php? What url are you calling?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, I'm trying to use a slug as a query for an API route, it's not working and returning a 404, but I'm unsure what I'm doing wrong.
Route::get('categories/{category:slug}', [CategoryController::class, 'show']);
public function show(Category $category)
{
return Category::find($category);
}
Please or to participate in this conversation.