当前位置: 首页>>代码示例>>PHP>>正文


PHP Currency::findOne方法代码示例

本文整理汇总了PHP中app\models\Currency::findOne方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::findOne方法的具体用法?PHP Currency::findOne怎么用?PHP Currency::findOne使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\Currency的用法示例。


在下文中一共展示了Currency::findOne方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addOperation

 public function addOperation()
 {
     if ($this->currency_id != '1') {
         $course = new Course();
         if (!$course->checkCourse($this->currency_id)) {
             $course->currency_id = $this->currency_id;
             $currency = Currency::findOne($this->currency_id);
             $course->course = $course->getCourse($currency->iso);
             if (!$course->save()) {
                 throw new ErrorException('Курс не обновлен' . var_dump($course));
             }
         }
     }
     $operation = new Operation();
     $operation->user_id = Yii::$app->getUser()->id;
     $operation->category_id = $this->category_id === '' ? 1 : $this->category_id;
     $operation->currency_id = $this->currency_id === '' ? 1 : $this->currency_id;
     $operation->summ = $this->operation_type == 'income' ? $this->summ * 100 : $this->summ * -100;
     $operation->description = $this->description;
     return $operation->save() ? $operation : null;
 }
开发者ID:Nhassa,项目名称:budget,代码行数:21,代码来源:OperationForm.php

示例2: function

        $country = $result->country['Name'];
    }
    return $country;
}], ['attribute' => 'ContactID', 'label' => 'Туристы', 'content' => function ($data) {
    $mainContact = $data->contact;
    $list = "<ul>";
    $list .= "<li>" . $mainContact['Name'] . " " . $mainContact['SurName'] . "</li>";
    foreach ($data->participants as $value) {
        $contact = Contact::findOne($value['ContactID']);
        $list .= "<li>" . $contact->Name . " " . $contact->SurName . "</li>";
    }
    $list .= "</ul>";
    return $list;
}], ['attribute' => 'CurrencyID', 'label' => 'Валюта', 'content' => function ($data) {
    $currency = '';
    $result = Currency::findOne($data->orderCalc['CurrencyID']);
    if (is_object($result)) {
        $currency = $result->Currency;
    }
    return $currency;
}], ['attribute' => 'Price', 'label' => 'Стоимость', 'content' => function ($data) {
    return $data->orderCalc['Price'];
}], ['attribute' => 'Charges', 'label' => 'Комиссия', 'content' => function ($data) {
    return $data->Charges;
}], ['attribute' => 'Sum', 'label' => 'Долг', 'content' => function ($data) {
    return $data->Sum - $data->Charges;
}, 'contentOptions' => function ($model, $key, $index, $column) {
    $status = '';
    $debt = $model->Sum - $model->Charges;
    if ($debt > 0) {
        $status = 'text-danger';
开发者ID:Dionnit,项目名称:Touristic,代码行数:31,代码来源:list.php

示例3: findModel

 /**
  * 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.');
     }
 }
开发者ID:Nhassa,项目名称:budget,代码行数:15,代码来源:CurrencyController.php

示例4: refreshRates

 /**
  * @throws InvalidConfigException
  */
 public static function refreshRates()
 {
     /** @var Currency $defaultCurrency */
     $defaultCurrency = Currency::findOne(['is_default' => 1]);
     if (!$defaultCurrency) {
         throw new InvalidConfigException('Default currency is not set.');
     }
     /** @var Currency[] $currencies */
     $currencies = Currency::find()->all();
     foreach ($currencies as $currency) {
         if ($currency->code == $defaultCurrency->code) {
             $currency->rate = 1;
         } else {
             $url = 'http://finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=' . $defaultCurrency->code . $currency->code . '=X';
             $handle = @fopen($url, 'r');
             if ($handle === false) {
                 throw new Exception('Can not connect to exchange rates provider service.');
             }
             $result = fgets($handle, 4096);
             fclose($handle);
             $currencyData = explode(',', $result);
             $currency->rate = $currencyData[1];
         }
         $currency->save();
     }
 }
开发者ID:vetoni,项目名称:toko,代码行数:29,代码来源:CurrencyHelper.php

示例5: setCourse

 public function setCourse($currency_id)
 {
     $this->currency_id = $currency_id;
     $currency = Currency::findOne($currency_id);
     $this->course = $this->getCourse($currency->iso);
     return $this->save() ? $this : null;
 }
开发者ID:Nhassa,项目名称:budget,代码行数:7,代码来源:Course.php


注:本文中的app\models\Currency::findOne方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。