/** * 提取设备系列id,并得到系列名称 */ private function getDeviceSeries($series_url) { $result = ['series_id' => 0, 'series_name' => '']; if (!empty($series_url)) { $pos = strripos($series_url, '/'); $series_id = substr($series_url, $pos + 1); $result['series_id'] = $series_id; if (!empty($series_id)) { $series = DeviceSeries::findOne($series_id); if (!empty($series)) { $result['series_name'] = $series['name']; } } } return $result; }
/** * 设备所属系列 * @return \yii\db\ActiveQuery */ public function getSeries() { return $this->hasOne(DeviceSeries::className(), ['id' => 'series_id']); }