Beispiel #1
0
 protected function fakeCurrency()
 {
     $fakeCurrency = new Currency();
     $fakeCurrency->currency_code = "USD";
     $fakeCurrency->currency_name = "Dollar";
     $fakeCurrency->save();
     return $fakeCurrency;
 }
Beispiel #2
0
 /**
  * Creates a new Currency model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Currency();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->goBack();
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Currency model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Currency();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         $billing = ArrayHelper::map(Billing::find()->asArray()->all(), 'id', 'name');
         return $this->render('create', ['model' => $model, 'billing' => $billing]);
     }
 }
 /**
  * Creates a new Currency model.
  * If creation is successful, the browser will be redirected to the 'index' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Currency();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash("Currency-success", Yii::t("app", "Currency successfully created"));
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Beispiel #5
0
 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;
     }
 }
 public function save($request)
 {
     $currencies = new Currency();
     $currencies->currency = $request->input('currency');
     $currencies->symbol = $request->input('symbol');
     if ($currencies->save()) {
         return $currencies->id;
     } else {
         return false;
     }
 }
 /**
  * @param Request $request
  * @param Course $course
  * @return \Illuminate\Http\RedirectResponse
  */
 public function store(Request $request, Course $course)
 {
     $regex = '/^(?=.+)(?:[1-9]\\d*|0)?(?:\\.\\d+)?$/';
     $validator = Validator::make($request->all(), ['name' => 'required|string|max:255', 'course_purchase' => ['required', 'regex:' . $regex]]);
     if ($validator->fails()) {
         return redirect()->route('admin.course.create')->withErrors($validator->errors())->withInput();
     }
     $currency = new Currency();
     $currency->name = $request->name;
     $currency->save();
     $course->currency()->associate($currency);
     $course->fill($request->all());
     $course->save();
     return redirect()->route('admin.course.index');
 }
Beispiel #8
0
 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;
 }