distinct()->pluck('station')->toArray(); // 构建一个关联数组来存储每个类型对应的代码 $typeCodes = []; foreach ($types as $type) { if ($options != []) { if (in_array($type, $options)) { $codes = self::where('station', $type)->pluck('serialnumber')->toArray(); $typeCodes[$type] = $codes; } } else { $codes = self::where('station', $type)->pluck('serialnumber')->toArray(); $typeCodes[$type] = $codes; } } return $typeCodes; } public static function getTypePrecinct($options = []) { // 获取所有的类型 $types = self::select('precinct')->distinct()->pluck('precinct')->toArray(); // 构建一个关联数组来存储每个类型对应的代码 $typeCodes = []; foreach ($types as $type) { // $type in $options if ($options != []) { if (in_array($type, $options)) { $codes = self::where('precinct', $type)->pluck('serialnumber')->toArray(); $typeCodes[$type] = $codes; } } else { $codes = self::where('precinct', $type)->pluck('serialnumber')->toArray(); $typeCodes[$type] = $codes; } } return $typeCodes; } }