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


PHP models\Currency类代码示例

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


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

示例1: globalData

 /**
  * Prepare global variables.
  * @return array
  */
 public static function globalData()
 {
     if (!Auth::check()) {
         $rows = null;
         $cart = null;
         $grandTotal = null;
     } else {
         $rows = Cart::instance(auth()->id())->count(false);
         $cart = Cart::instance(auth()->id())->content();
         $grandTotal = Cart::instance(auth()->id())->total();
     }
     $data = array('menu' => self::getMenuData(self::$parent_id), 'header' => Setting::findOrFail(1), 'rows' => $rows, 'cart' => $cart, 'grand_total' => $grandTotal, 'currencies' => Currency::all());
     return $data;
 }
开发者ID:raylight75,项目名称:cms,代码行数:18,代码来源:GlobalComposer.php

示例2: fakeCurrency

 protected function fakeCurrency()
 {
     $fakeCurrency = new Currency();
     $fakeCurrency->currency_code = "USD";
     $fakeCurrency->currency_name = "Dollar";
     $fakeCurrency->save();
     return $fakeCurrency;
 }
开发者ID:boylee1111,项目名称:Reservation,代码行数:8,代码来源:DbTestCase.php

示例3: __construct

 public function __construct(Currency $currencyModel, Note $noteModel)
 {
     $notes = $noteModel->getLastNote();
     if (count($notes) < 1) {
         $notes = false;
     }
     //GLOBAL SETTINGS
     $this->_glob = array('_note' => $notes, '_curr' => $currencyModel->getRate(), '_baseCurrency' => 'RUB', '_precision' => 2, '_countProductsOfPage' => Auth::User() ? Auth::User()->count_products : 100, '_maxCountProductsOfPage' => 500, '_alerts' => AbsentController::shortView());
     View::share('_glob', $this->_glob);
 }
开发者ID:enotsokolov,项目名称:vp_plus,代码行数:10,代码来源:Controller.php

示例4: initCurrenciesToDb

 private function initCurrenciesToDb()
 {
     for ($day = 3000; $day > 0; $day--) {
         $currency = new Currency();
         $date = date('Y-m-d', strtotime('-' . $day . ' day'));
         $currency->date = $date;
         $currency->usd = $this->getCurrencyForDate($date);
         $currency->save();
         echo $day . PHP_EOL;
     }
 }
开发者ID:sasik-github,项目名称:currency,代码行数:11,代码来源:MyCommand.php

示例5: actionGetCurrencies

 public function actionGetCurrencies()
 {
     $billing_id = Yii::$app->request->post('billing_id');
     $currencies = ArrayHelper::map(Currency::find()->where("billing_id = :billing_id", [':billing_id' => $billing_id])->with('billing')->asArray()->all(), 'id', 'name');
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return $currencies;
 }
开发者ID:zinchenkomax,项目名称:moneychanger,代码行数:7,代码来源:RateController.php

示例6: show

 /**
  * Change the currency.
  *
  * @return Redirect
  */
 public function show(Request $request, string $currency)
 {
     $request->session()->put('currency', $currency);
     $currency = Currency::where('currency', $currency)->first()->toArray();
     $request->session()->put('currency_rate', $currency['rate']);
     // we need to update the basket
     $basket = $request->session()->get('basket');
     foreach ($basket['items'] as $id => $item) {
         if (isset($item['parent_sku'])) {
             // its an option
             $product = Product::where('sku', $item['parent_sku'])->first();
             $price = isset($product->salePrice) && !empty($product->salePrice) ? $product->salePrice : $product->price;
             foreach ($product->option_values as $option) {
                 if ($option['sku'] == $id) {
                     $price = number_format($option['price'] * $request->session()->get('currency_rate'), 2, '.', '');
                 }
             }
         } else {
             $product = Product::find($id);
             $price = isset($product->salePrice) && !empty($product->salePrice) ? $product->salePrice : $product->price;
         }
         $basket['items'][$id]['price'] = $price;
     }
     $request->session()->put('basket', $basket);
     return redirect()->back();
 }
开发者ID:kudosagency,项目名称:kudos-php,代码行数:31,代码来源:CurrenciesController.php

示例7: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('course')->delete();
     Model::unguard();
     $faker = Faker\Factory::create();
     $currencies = Currency::all()->toArray();
     DB::table('course')->insert([['currency_id' => $currencies[0]['id'], 'course_purchase' => 5.4, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[1]['id'], 'course_purchase' => 5.0, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[2]['id'], 'course_purchase' => 1.03, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[3]['id'], 'course_purchase' => 1.7, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[4]['id'], 'course_purchase' => 1.7, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[5]['id'], 'course_purchase' => 1.0, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[6]['id'], 'course_purchase' => 0.1, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[7]['id'], 'course_purchase' => 0.3, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[8]['id'], 'course_purchase' => 0.1, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[9]['id'], 'course_purchase' => 0.00014, 'wallet' => $faker->creditCardNumber], ['currency_id' => $currencies[10]['id'], 'course_purchase' => 0.0, 'wallet' => $faker->creditCardNumber]]);
     Model::reguard();
 }
开发者ID:lyovkin,项目名称:elcoinbank,代码行数:14,代码来源:CourseTableSeeder.php

示例8: exchangeRates

 public function exchangeRates()
 {
     $currency = new Currency();
     $url = 'https://api.privatbank.ua/p24api/pubinfo?exchange&coursid=3';
     $xml = new SimpleXMLElement($url, NULL, true);
     $eur = (array) $xml->row[0]->exchangerate['sale'];
     $rur = (array) $xml->row[1]->exchangerate['sale'];
     $usd = (array) $xml->row[2]->exchangerate['sale'];
     $currency->uan = 1;
     $currency->eur = $eur[0];
     $currency->rur = $rur[0];
     $currency->usd = $usd[0];
     $currency->date = 86400 * ceil(time() / 86400);
     if ($currency->save()) {
         return false;
     }
     return true;
 }
开发者ID:aiskimzhi,项目名称:advert,代码行数:18,代码来源:Currency.php

示例9: getActiveCurrency

 public static function getActiveCurrency($chCode = false)
 {
     $attr = 'name';
     $query = Currency::find()->andWhere(['active' => true])->all();
     if ($chCode) {
         $attr = 'chCode';
     }
     return ArrayHelper::map($query, 'id', $attr);
 }
开发者ID:alexus007,项目名称:budget,代码行数:9,代码来源:Currency.php

示例10: actionUpdate

 /**
  * Updates an existing Rate model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $currency_list = Currency::getCurrencyList();
         return $this->render('update', ['model' => $model, 'currency' => $currency_list]);
     }
 }
开发者ID:zinchenkomax,项目名称:moneychanger,代码行数:16,代码来源:RateController.php

示例11: currency

 /**
  *
  * Helper Currency Class
  *
  * @package ecommerce-cms
  * @category Helper Class
  * @author Tihomir Blazhev <raylight75@gmail.com>
  * @link https://raylight75@bitbucket.org/raylight75/ecommerce-cms.git
  */
 public static function currency($input)
 {
     $var = session('currency');
     if (isset($var)) {
         $currency = Currency::where('name', '=', $var)->first();
         $rate = $currency->rate;
     } else {
         $rate = 1;
     }
     $total = (double) $input * (double) $rate;
     return number_format((double) $total, 2);
 }
开发者ID:raylight75,项目名称:cms,代码行数:21,代码来源:Helper.php

示例12: actionCreate

 /**
  * Creates a new Account model.
  * If creation is successful, the browser will be redirected to the 'index' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Account();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash("Account-success", Yii::t("app", "Account successfully created"));
         return $this->redirect(['index']);
     } else {
         $currencyItems = Currency::find()->select(['id', 'name'])->where(['user_id' => Yii::$app->user->id])->asArray()->all();
         $currencyItems = ArrayHelper::map($currencyItems, 'id', 'name');
         return $this->render('create', ['model' => $model, 'currencyItems' => $currencyItems]);
     }
 }
开发者ID:ercling,项目名称:economizzer,代码行数:17,代码来源:AccountController.php

示例13: postSetActive

 public function postSetActive()
 {
     $id = Input::get('id');
     Currency::where('active', 1)->update(['active' => 0]);
     $currency = Currency::find($id);
     if ($currency) {
         $currency->active = 1;
         $currency->save();
         return Redirect::back()->with('message', "Курс валюты '{$currency->title}' обновлён");
     }
     return Redirect::back()->with('message', 'Ошибка обновления');
 }
开发者ID:venomir,项目名称:tc,代码行数:12,代码来源:CurrencyController.php

示例14: price

 public function price()
 {
     $active_currency = Currency::active();
     $price = $this->price * $active_currency->rate_ue * $active_currency->rate_rub;
     if ($this->is_default_discount > 0) {
         $default_discount_sum = $price / 100 * $this->default_discount;
         $price -= $default_discount_sum;
     }
     if (Auth::check()) {
         $price -= $this->personal_discount($price);
     }
     return $price;
 }
开发者ID:venomir,项目名称:tc,代码行数:13,代码来源:Product.php

示例15: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Currency::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'iso', $this->iso])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
开发者ID:Nhassa,项目名称:budget,代码行数:21,代码来源:CurrencySearch.php


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