Level 55
@nobodyownz for example for url /?count=orders
$query->when(request('count') == 'orders', fn ($query) => $query->withCount('orders'))
4 likes
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How can I add a total count on a Laravel API response only if there is a query params? example:
/?count(orders)
@nobodyownz for example for url /?count=orders
$query->when(request('count') == 'orders', fn ($query) => $query->withCount('orders'))
Please or to participate in this conversation.