123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- <?php
- namespace app\models\entity\ar;
- use yii\db\ActiveRecord;
- /**
- * @property int id
- * @property string name
- * @property string name_display
- * @property float size_x
- * @property float size_y
- * @property float size_z
- * @property string imageA (base64)
- * @property string imageB (base64)
- * @property string imageC (base64)
- * @property string imageD (base64)
- * @property string imageE (base64)
- * @property string imageF (base64)
- * @property int $angleA [int(11)]
- * @property int $angleB [int(11)]
- * @property int $angleC [int(11)]
- * @property int $angleD [int(11)]
- * @property int $angleE [int(11)]
- * @property int $angleF [int(11)]
- * @property int status
- * @property string $target_name_xml [varchar(255)]
- * @property string $type
- * @property-read Stage[] $stages
- */
- class TargetObject extends ActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return 'ar_targetobjects';
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'name' => 'Имя объекта',
- 'name_display' => 'Заголовок',
- 'size_x' => 'Координата x',
- 'size_y' => 'Координата y',
- 'size_z' => 'Координата z',
- 'imageA' => 'Изображение А',
- 'imageB' => 'Изображение B',
- 'imageC' => 'Изображение C',
- 'imageD' => 'Изображение D',
- 'imageE' => 'Изображение E',
- 'imageF' => 'Изображение F',
- 'angleA' => 'Угол A',
- 'angleB' => 'Угол B',
- 'angleC' => 'Угол C',
- 'angleD' => 'Угол D',
- 'angleE' => 'Угол E',
- 'angleF' => 'Угол F',
- 'status' => 'Статус',
- 'target_name_xml' => 'Имя из xml файла',
- 'type' => 'Тип'
- ];
- }
- public function fillFromArray(array $params)
- {
- foreach ($params as $key => $value) {
- $this->$key = $params[$key];
- }
- $this->status = $params['status'] ?? 1;
- }
- public function asArray()
- {
- $targetObject = [];
- foreach ($this->fields() as $fieldName) {
- $targetObject[$fieldName] = $this->$fieldName;
- }
- return $targetObject;
- }
- public function getStages()
- {
- $this->hasOne(Stage::class, ['object_id' => 'id']);
- }
- }
|