示例#1
0
 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;
     }
 }
 /**
  * Deletes an existing Goods model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     \common\models\UploadHelpers::deleteFile($model->picture, Yii::$app->basePath . '/web/uploads');
     $model->delete();
     return $this->redirect(['index']);
 }