cursor() as $relation) { $all++; if (! empty($relation->to)) { $old = json_decode($relation->to, true); if (count(array_filter(array_keys($old), 'is_string')) === 0) { // 索引数组,需要转换 $new = ['case' => $old]; Relation::where('id', $relation->id)->update(['to' => json_encode($new)]); $count++; } } } $this->info("{$count} of {$all}"); return 0; } }