chunk in laravel code example
Example 1: wherein laravel
DB::table('user')->whereIn('id', [100,200])->get();
Example 2: 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 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) {
}
});