select("call proc_child('{$this->ancestors}')"); $descendants = array_pluck($descendants, 'custom_no'); $select = ['id', 'custom_no as sn', 'name', 'create_time as created_at', 'update_time as updated_at', 'del']; $data = DB::connection('real')->table('jxc_custom')->select($select) ->where(function ($query) use ($descendants) { $query->whereIn('custom_no', $descendants)->where('cLevel', 1); })->orWhere('custom_no', 'No00000000836') ->get(); $array = []; foreach ($data as $item) { $item = (array)$item; $item['name'] = trim($item['name']); $item['created_at'] = is_numeric($item['created_at']) ? Carbon::createFromTimestamp($item['created_at']) : Carbon::parse($item['created_at']); $item['updated_at'] = is_numeric($item['updated_at']) ? Carbon::createFromTimestamp($item['updated_at']) : Carbon::parse($item['updated_at']); $item['deleted_at'] = $item['del'] ? $item['updated_at'] : null; unset($item['del']); $array[] = $item; } Company::upsert($array, 'id'); app(CompanyRepository::class)->forgetCached(); } }