getDateTime(); $sql = "SELECT c.id,c.custom_no AS sn,c.name,c.create_time AS created_at,c.del FROM jxc_user a INNER JOIN jxc_user_custom_relation b ON a.id=b.uid INNER JOIN jxc_custom c ON b.custom_no=c.custom_no WHERE a.parent_user IN (SELECT id FROM jxc_user WHERE parent_user=3 AND role_tag='normal')"; $data = DB::connection('real')->select($sql); foreach ($data as &$item) { $item = (array)$item; $item['created_at'] = Carbon::parse($item['created_at']); $item['updated_at'] = date('Y-m-d H:i:s'); $item['deleted_at'] = $item['del'] ? date('Y-m-d H:i:s') : null; unset($item['del']); } Company::upsert($data, 'id'); app(CompanyRepository::class)->forgetCached(); } }