'國際路二段與大興西三段', '桃園區復興路與民生路口' => '復興路與民生路', '桃園區三民路二段與春日路口' => '三民二段與春日路', '桃園區中山路與上海路口' => '中山路與上海路', '桃園區三民路二段與民生路口' => '三民路二段與民生路', '桃園區春日路與民光東路口' => '春日路與民光東路', '桃園區三民路三段與永安路口' => '三民路三段與永安路', '蘆竹區中正路與南山路一段路口' => '蘆竹中正路與南山路一段', '八德區中華路與永豐路口' => '八德中華路與永豐路', '八德區建德路與豐德路口' => '八德建德路與豐德路', ]; $name = $match[$this->location] ?? $this->location; return $name; } public function getCustodyunitNameAttribute() { $name = CustodyUnit::find($this->custodyunit_id)->name ?? '無'; return $name; } public function getAssetownershipNameAttribute() { $name = AssetOwnership::find($this->assetownership_id)->name ?? '無'; return $name; } // 有關聯到設備保管單位 public function custodyunit() { return $this->belongsTo(CustodyUnit::class, 'custodyunit_id', 'id'); } // 有關聯到設備財產權屬 public function assetownership() { return $this->belongsTo(AssetOwnership::class, 'assetownership_id', 'id'); } // 有關聯到 public static function getTypeStation($options = []) { // 获取所有的类型 $types = self::select('station')->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; } }