本文整理汇总了PHP中app\models\Currency::addNewCurrency方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::addNewCurrency方法的具体用法?PHP Currency::addNewCurrency怎么用?PHP Currency::addNewCurrency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Currency
的用法示例。
在下文中一共展示了Currency::addNewCurrency方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request, Currency $currencyModel, History $historyModel)
{
if (isset($_POST['upd_currency_sbmt'])) {
if (!right('UpdateCurrency')) {
abort(404);
}
if (empty($_POST['upd_value'])) {
Session::flash('message', GetMessages("ERROR_EMPTY_CURR_VALUE"));
return redirect()->route('currency.index');
}
$value = trim(str_replace(',', '.', $_POST['upd_value']));
$value = floatval($value);
$arFields = array('currency_id' => $_POST['upd_currency_id'], 'rate' => $value, 'old_rate' => $currencyModel->getRateById($_POST['upd_currency_id']), 'user_id' => Auth::User()->id);
$currencyModel->updateCurrency($arFields);
$historyModel->saveHistory('update_rate', $arFields);
Session::flash('message', GetMessages("SUCCESS_ADDING_CURR_VALUE"));
return redirect()->route('currency.index');
}
if (isset($_POST['new_currency_sbmt'])) {
if (!right('UpdateCurrency')) {
abort(404);
}
$name = trim($_POST['new_currency']);
if (empty($name)) {
Session::flash('message', GetMessages("ERROR_NEW_CURR_EMPTY"));
return redirect()->route('currency.index');
}
if (strlen($name) < 3 or strlen($name) > 3) {
Session::flash('message', GetMessages("ERROR_NEW_CURR_NOT_THREE"));
return redirect()->route('currency.index');
}
$arFields = array('currency' => mb_strtoupper($name), 'desc' => $_POST['new_desc']);
$currencyModel->addNewCurrency($arFields);
$historyModel->saveHistory('create_currency', $name);
Session::flash('message', GetMessages("SUCCESS_ADDING_NEW_CURR"));
return redirect()->route('currency.index');
}
}