getDateTime(); $starttime = new UTCDateTime($datetime->copy()->startOfDay()->startOfMonth()->timestamp * 1000); $endtime = new UTCDateTime($datetime->copy()->endOfDay()->endOfMonth()->timestamp * 1000); $res = DB::connection('mongo')->table('tblCard')->select(['cNo', 'saDate']) ->where('pNo', 'No00000000768') ->where('isDel', '<>', 1) ->whereBetween('saDate', [$starttime, $endtime])->get(); $list = $res->map(function ($item) { return [ 'sim' => $item['cNo'], 'activate_at' => $item['saDate']->toDateTime()->format('Y-m-d H:i:s'), ]; })->toArray(); foreach (array_chunk($list, 10000) as $data) { Card::updateBatch($data, 'sim'); } } }