slave_db; } /** * {@inheritdoc} */ public function rules() { return [ [['cond', 'date', 'device_id', 'token'], 'required'], [['device_id', 'send_date'], 'integer'], [['cond'], 'string', 'max' => 5], [['token','date'], 'unique', 'targetAttribute' => ['date', 'token']], [['date', 'token', 'send_ip'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'cond' => 'Состояние', 'device_id' => 'Номер устройства(масломер)', 'date' => 'Дата', 'token' => 'Метка (rfid)', 'location' => 'Расположение клёсной пары', 'section_number' => 'Номер секции', 'send_date' => 'Дата отправки показаний', 'send_ip' => 'IP с которого пришли показания' ]; } /** * @return \yii\db\ActiveQuery */ public function getWheelpairs() { return $this->hasOne(WheelPairs::class, ['token' => 'token']); } public function getLocation() { if ($this->location) return $this->location; $location = explode('/', $this->token); return $location[1] ?? null; } }