1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php /** Created by Anton on 29.01.2020. */
- namespace app\models\entity;
- /**
- * This is the model class for table "user_device".
- *
- * @property int $id
- * @property int $employee
- * @property int $phone
- * @property int $camera
- * @property int $oil_meter
- */
- class UserDevice extends \yii\db\ActiveRecord
- {
- const PHONE_FIELD = 'phone';
- const CAMERA_FIELD = 'camera';
- const OIL_METER_FIELD = 'oil_meter';
- private $fields = [
- 1 => 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];
- }
- }
|