📜  laravel 中的块 - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:08.892000             🧑  作者: Mango

代码示例4
$data = Inspector::latest('id')
    ->select('id', 'firstname', 'status', 'state', 'phone')
    ->where('firstname', 'LIKE', '%' . $searchtext . '%')
    ->chunk(50, function($inspectors) {
        foreach ($inspectors as $inspector) {
            // apply some action to the chunked results here
        }
    });