200], [['width', 'height'], 'required'], ['title', 'unique', 'targetClass' => '\common\models\Slider', 'message' => Yii::t('app','message',[ 'field' => 'Title' ])], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'slider_id' => Yii::t('app', 'slider_id'), 'speed' => Yii::t('app', 'speed'), 'duration' => Yii::t('app', 'duration'), 'title' => Yii::t('app', 'title'), 'status' => Yii::t('app', 'status'), 'width' => Yii::t('app', 'width'), 'height' => Yii::t('app', 'height'), ]; } /** * @return \yii\db\ActiveQuery */ public function getSliderImage() { return $this->hasMany(SliderImage::className(), ['slider_id' => 'slider_id'])->where([SliderImage::tableName().'.status'=>1]); } /** * fetch stored image file name with complete path * @return string */ public function getImageFile() { return isset($this->image) ? '/storage/slider/' . $this->image : null; } /** * fetch stored image url * @return string */ public function getImageUrl() { // return a default image placeholder if your source image is not found return isset($this->image) ? '/storage/slider/'. $this->image : '/storage/no_photo.png'; } }