Reputation: 363
I'm trying to split some processing on my models process in several jobs. Let's say I have 300 models I want to process. I want to launch 3 jobs, each job will handle 100 models. In each job, I want to lazy load by group of 10 models.
If I execute the following code :
$models = MyModel::offset(0)->limit(100)->lazy(10);
$j = 0;
foreach ($models as $model) {
$j++;
}
echo $j;
The output is :
300
Where I thought only 100 models should be processed.
I don't understand why all my models are processed.
If someone knows the truth ... :)
Upvotes: 2
Views: 1293
Reputation: 363
Well, it seems I got lost, this works:
MyModel::lazy(10)->skip(0)->take(100);
Upvotes: 7