'array' ]; /** * The attributes excluded from the model's JSON form. * * @var array */ protected $hidden = []; /** * 获取名称 * @return array */ public static function getNames() { $sourceMatters = self::query()->where('status', ModelStatusEnum::OK)->get(); $data = []; foreach ($sourceMatters as $sourceMatter) { $da = $sourceMatter->similar_name; if (!is_array($da)) $da = []; $da[] = $sourceMatter->name; $data[] = [ 'id' => $sourceMatter->id, 'names' => $da, ]; } return $data; } }