Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JamesZimmerman's avatar

Laravel Nova - Problems with distinct()

I am using Laravel Nova to generate metrics, in this case specifically a trend. Here is my code:

$builder = order::query()->select('cook_id')->distinct(); return $this->countByDays($request, $builder)->showLatestValue();

However this is returning 6 - but it should be 4.

Yes there are 6 rows, but four of them have the same 'cook_id' and thus the distinct call should be eliminating 2 of those.

To reiterate, this is in Laravel Nova's "trend" metric.

Thanks

0 likes
0 replies

Please or to participate in this conversation.