laravel chunking code example
Example 1: how to return chunk data laravel
$count = 0;
DB::table('users')->chunk(200, function($users) use (&$count)
{
Log::debug(count($users));
$count = $count + count($users);
});
Log::debug($count);
Example 2: php artisan make model
php artisan make:model Flight
Example 3: get data from model in chunks laravel
$data = Inspector::latest('id')
->select('id', 'firstname', 'status', 'state', 'phone')
->where('firstname', 'LIKE', '%' . $searchtext . '%')
->chunk(50, function($inspectors) {
foreach ($inspectors as $inspector) {
}
});