self::CAMERA_FIELD, 2 => self::OIL_METER_FIELD, 3 => self::PHONE_FIELD ]; /** * {@inheritdoc} */ public static function tableName() { return 'user_device'; } /** * {@inheritdoc} */ public function rules() { return [ [['employee', 'phone', 'camera', 'oil_meter'], 'integer'], ]; } /** * @return \yii\db\ActiveQuery */ public function getEmployee() { return $this->hasOne(Accounts::class, ['id' => 'employee']); } /** * @return \yii\db\ActiveQuery */ public function getPhone() { return $this->hasOne(Log::class, ['id' => 'phone']); } /** * @return \yii\db\ActiveQuery */ public function getCamera() { return $this->hasOne(Log::class, ['id' => 'camera']); } /** * @return \yii\db\ActiveQuery */ public function getOilMeter() { return $this->hasOne(Log::class, ['id' => 'oil_meter']); } public function getFieldNameById(int $id) { return $this->fields[$id]; } }