public function beforeSave($insert) { if (parent::beforeSave($insert)) { $oldFileName = $this->picture; \common\models\UploadHelpers::saveFile($this, 'picture', $oldFileName, Yii::$app->basePath . '/web/uploads'); $this->price_with_vat = (int) (1.1 * $this->price_without_vat); if ($this->price_without_vat != 0) { $this->percentage = (int) (100 * $this->increment_price / $this->price_without_vat - 100); } else { $this->percentage = $this->increment_price; } return true; } else { return false; } }