1024], [['type_map'], 'in', 'range' => array_keys(MainModule::typeRange())], [['published', 'deleted'], 'in', 'range' => array_keys(static::statusKeyRange())], [['position'], 'default', 'value' => 0], [['published'], 'default', 'value' => self::STATUS_KEY_ON] ]; } /** * @return array */ public function scenarios() { return [ 'published' => ['published'], 'deleted' => ['deleted'], 'backend' => [ 'image_link', 'image_link2', 'type_map', 'position', 'published', 'deleted', ], ]; } /** * @return array */ public function attributeLabels() { return [ 'id' => Yii::t('app', 'ID'), 'image_link' => Yii::t('app', 'Image link'), 'image_link2' => Yii::t('app', 'Image link'), 'type_map' => Yii::t('map', 'Type'), 'position' => Yii::t('app', 'Position'), 'created_at' => Yii::t('app', 'Create time'), 'updated_at' => Yii::t('app', 'Update time'), 'published' => Yii::t('app', 'Published'), 'deleted' => Yii::t('app', 'Deleted'), ]; } /** * @return \yii\db\ActiveQuery */ public function getLang() { return $this->hasOne(AreaLang::class, ['rid' => 'id']); } /** * @return Module|null the module instance, `null` if the module does not exist. */ /** * @return null|\yii\base\Module */ public static function getModule() { return Yii::$app->getModule(self::moduleName); } /** * @return null|string */ public function getImageLink() { $module = $this->getModule(); $path = $module->getItemUploadPath(); $url = $module->getItemUploadUrl(); return (!empty($this->image_link) && is_file($path . '/' . $this->image_link)) ? $url . '/' . $this->image_link : null; } /** * @return null|string */ public function getImageLink2() { $module = $this->getModule(); $path = $module->getItemUploadPath(); $url = $module->getItemUploadUrl(); return (!empty($this->image_link2) && is_file($path . '/' . $this->image_link2)) ? $url . $this->image_link2 : null; } /** * @return null|string */ public function getImageLink2Path() { $module = $this->getModule(); $path = $module->getItemUploadPath(); $url = $module->getItemUploadUrl(); return (!empty($this->image_link2) && is_file($path . '/' . $this->image_link2)) ? $path . $this->image_link2 : null; } }