本文整理汇总了PHP中app\models\Currency::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::save方法的具体用法?PHP Currency::save怎么用?PHP Currency::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Currency
的用法示例。
在下文中一共展示了Currency::save方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fakeCurrency
protected function fakeCurrency()
{
$fakeCurrency = new Currency();
$fakeCurrency->currency_code = "USD";
$fakeCurrency->currency_name = "Dollar";
$fakeCurrency->save();
return $fakeCurrency;
}
示例2: actionCreate
/**
* 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]);
}
}
示例3: actionCreate
/**
* 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]);
}
}
示例4: actionCreate
/**
* 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]);
}
}
示例5: 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;
}
}
示例6: save
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;
}
}
示例7: store
/**
* @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');
}
示例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;
}