get data from model in chunks laravel

Solutions on MaxInterview for get data from model in chunks laravel by the best coders in the world

showing results for - "get data from model in chunks laravel"
Neele
04 Nov 2017
1$data = Inspector::latest('id')
2    ->select('id', 'firstname', 'status', 'state', 'phone')
3    ->where('firstname', 'LIKE', '%' . $searchtext . '%')
4    ->chunk(50, function($inspectors) {
5        foreach ($inspectors as $inspector) {
6            // apply some action to the chunked results here
7        }
8    });