H
H
harry9992021-03-10 13:42:45
Laravel
harry999, 2021-03-10 13:42:45

How to fix 500 error when fetching Laravel Eloquent records?

Good afternoon, I encountered such a situation, I have a large database of about 1 million lines.
It is necessary to generate statistics of orders by day.
I do it like this:

$orders = Order::filter(Order::query());
$orders->where('status', 1)->get()->groupBy(function($item){ return $item->created_at->format('Y-m-d'); });
// Вот при последним запросе, выбивает 500 ошибка. Пытаюсь получить записи за последние 30 дней, около 60.000 строк.

I will be grateful for your help!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2021-03-10
@harry999

"Error 500" is fixed in the logs, read them to find out what exactly is wrong.
Maybe you don't have enough memory for the script, or maybe the created_at field is empty somewhere - it could be anything.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question