本文整理汇总了PHP中app\models\Currency::where方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::where方法的具体用法?PHP Currency::where怎么用?PHP Currency::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Currency
的用法示例。
在下文中一共展示了Currency::where方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: 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', 'Ошибка обновления');
}
示例3: 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);
}
示例4: __construct
public function __construct(Route $route)
{
$this->middleware(function ($request, $next) {
// if session is not set get it from .env SHOP_CODE
if (!$request->session()->has('shop')) {
$shop = Shop::where('code', config('app.shop_code'))->first();
$request->session()->put('shop', $shop->id);
}
// if limit is not set default pagination limit
if (!$request->session()->has('limit')) {
$request->session()->put('limit', 102);
}
// if session is not set reset the session for the language
if (!$request->session()->has('language')) {
$request->session()->put('language', config('app.locale'));
}
// if session is not set reset the session for the currency
if (!$request->session()->has('currency')) {
$request->session()->put('currency', config('app.currency'));
}
if (!$request->session()->has('currency_rate')) {
$currency = Currency::where('currency', config('app.currency'))->first();
$request->session()->put('currency_rate', $currency->rate);
}
// if session is not set reset the session for the basket
if (!$request->session()->has('basket')) {
$request->session()->put('basket', ['subtotal' => 0, 'count' => 0, 'items' => []]);
}
// global list of categories
if (!$request->session()->has('categories')) {
$categories = Category::where('shop_id', $request->session()->get('shop'))->orderBy('order', 'asc')->get()->toArray();
$request->session()->put('categories', $categories);
}
// global list of product filters
if (!$request->session()->has('filters')) {
$options = Option::all()->toArray();
// Serialization of 'MongoDB\BSON\ObjectID' is not allowed
$request->session()->put('filters', $options);
}
// share globals
view()->share('language', $request->session()->get('language'));
return $next($request);
});
// add controller & action to the body class
$currentAction = $route->getActionName();
list($controller, $method) = explode('@', $currentAction);
$controller = preg_replace('/.*\\\\/', '', $controller);
$action = preg_replace('/.*\\\\/', '', $method);
view()->share('body_class', $controller . '-' . $action);
}
示例5: listing
public function listing($page, $limit)
{
$response = array('data' => array(), 'paginator' => '');
if (!empty($limit)) {
$currencies = Currency::paginate($limit);
} else {
$currencies = Currency::where('id', '>', '0')->get();
}
if (!empty($currencies)) {
foreach ($currencies as $key => $currency) {
$response['data'][] = $this->get($currency->id, false);
}
}
if (!empty($limit)) {
$response = Utility::paginator($response, $currencies, $limit);
}
return $response;
}
示例6: destroy
/**
* @param Course $course
* @return \Illuminate\Http\RedirectResponse
* @throws \Exception
*/
public function destroy(Course $course)
{
$currency = Currency::where('id', $course->currency_id)->first();
$currency->delete();
$course->delete();
return back();
}