1

I have a Laravel query:

$var = Model::with(['rel1','rel2.1','rel2.2','rel2.3','rel3','rel4'])
->whereBetween('datum', [$start, $end])
->get();

If $var has more than 1000 items the hasMany relationships return an empty collection. If the same query has less than 1000 items the relationships are fine.

I have tried to set the PHP ini settings:

ini_set('memory_limit', '512M');

ini_set('max_input_vars', 30000);

ini_set('max_execution_time', 380);

But nothing worked so far.

On localhost everything works as expected, this issue only apears on the web server. Laravel is 5.4, PHP version 7.2.24

I'd like to get the relationships even if the collection is largen than 1000.

Thanks for your help.

Zsolti
  • 11
  • 1
  • The correct way is to paginate your result and use chunk here https://laravel.com/docs/5.4/eloquent#chunking-results – yangqi Apr 01 '22 at 21:51
  • I chunked the query and it worked perfectly. Thank you very much for your answer! – Zsolti Apr 04 '22 at 13:14

0 Answers0