255, ], [ [ 'image' ], 'safe', ], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'car_id' => Yii::t('app', 'Ідентификатор'), 'model' => Yii::t('app', 'Модель'), 'year' => Yii::t('app', 'Год производства'), 'image' => Yii::t('app', 'Изображение'), 'color' => Yii::t('app', 'Цвет'), 'mileage' => Yii::t('app', 'Пробег'), 'build' => Yii::t('app', 'Дата выпуска'), 'option' => Yii::t('app', 'Доп. опции'), 'price' => Yii::t('app', 'Цена'), ]; } public function upload() { /** * @var UploadedFile $image */ $this->image = UploadedFile::getInstance($this, 'image'); $image = $this->image; if(!empty( $image )) { $fullName = $image->baseName . time() . '.' . $image->extension; $path = Yii::getAlias('@storage') . '/' . $fullName; $image->saveAs($path); $image->name = '/storage/' . $fullName; } else { $this->image = $this->getOldAttribute('image'); } return true; } }