/**
  * Finds the Currency model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Currency the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Currency::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #2
0
 /**
  * @return float|int
  * Gets discount price
  */
 public function getSalePrice()
 {
     $price = $this->price;
     if (!empty($this->sale)) {
         if (!empty($this->type)) {
             if ($this->type->title == "money") {
                 $price = $this->price - $this->sale;
             } else {
                 if ($this->type->title == "percent") {
                     $price = $this->price - $this->price / 100 * $this->sale;
                 }
             }
         }
     }
     if (\Yii::$app->getModule('shop')->enableCurrencyConversion) {
         $price = floor($price * Currency::currentCurrency());
     }
     return $price;
 }