A class with one __invoke method gives an action its own name and dependencies. make:controller ShowBestsellers --invokable creates it, and the route names only the class: Route::get('/bestsellers', ShowBestsellers::class).
public function __invoke(Request $request): array
{
return Product::withAvg('reviews as rating', 'rating')
->orderByDesc('rating')->orderBy('name')
->limit(min($request->integer('limit', 3), 10))->get(['id', 'name'])
->map(fn (Product $p) => "{$p->name} (" . ($p->rating ?? '-') . ')')->all();
}Output
$ curl -s "$B/bestsellers?limit=2" ["Modern PHP (4.5)","Dune (-)"]
Name them as verb phrases (PublishProduct, HandleStripeWebhook) so the directory reads as a list of use cases; they suit webhooks, reports and pages that belong to no resource.