芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/store.kwesioben.com/app/Http/Controllers/Admin/CurrencyController.php
has('search')) { $key = explode(' ', $request['search']); $currencies = Currency::where(function ($q) use ($key) { foreach ($key as $value) { $q->Where('name', 'like', "%{$value}%"); } }); $query_param = ['search' => $request['search']]; } else { $currencies = new Currency(); } $currencies = $currencies->paginate(Helpers::pagination_limit())->appends($query_param); return view('admin-views.currency.view', compact('currencies', 'search')); } public function store(Request $request) { $currency = new Currency; $currency->name = $request->name; $currency->symbol = $request->symbol; $currency->code = $request->code; $currency->exchange_rate = $request->has('exchange_rate') ? $request->exchange_rate : 1; $currency->save(); Toastr::success(translate('New_Currency_inserted_successfully')); return redirect()->back(); } public function edit($id) { $data = Currency::find($id); return view('admin-views.currency.edit', compact('data')); } public function update(Request $request, $id) { $currency = Currency::find($id); if ($currency['code'] == 'BDT' && $request->code != 'BDT') { $config = Helpers::get_business_settings('ssl_commerz_payment'); if ($config['status']) { Toastr::warning(translate('Before_update_BDT').", ".translate('disable_the_SSLCOMMERZ_payment_gateway.')); return back(); } } elseif ($currency['code'] == 'INR' && $request->code != 'INR') { $config = Helpers::get_business_settings('razor_pay'); if ($config['status']) { Toastr::warning(translate('Before_update_INR').", ".translate('disable_the_RAZOR_PAY_payment_gateway.')); return back(); } } elseif ($currency['code'] == 'MYR' && $request->code != 'MYR') { $config = Helpers::get_business_settings('senang_pay'); if ($config['status']) { Toastr::warning(translate('Before_update_MYR').", ".translate('disable_the_SENANG_PAY_payment_gateway.')); return back(); } } elseif ($currency['code'] == 'ZAR' && $request->code != 'ZAR') { $config = Helpers::get_business_settings('paystack'); if ($config['status']) { Toastr::warning(translate('Before_update_ZAR').", ".translate('disable_the_PAYSTACK_payment_gateway.')); return back(); } } $currency->name = $request->name; $currency->symbol = $request->symbol; $currency->code = $request->code; $currency->exchange_rate = $request->has('exchange_rate') ? $request->exchange_rate : 1; $currency->save(); Toastr::success(translate('currency_updated_successfully')); return redirect()->back(); } public function delete(Request $request) { if (!in_array($request->id, [1, 2, 3, 4, 5])) { Currency::where('id', $request->id)->delete(); return response()->json(['status' => 1]); } else { return response()->json(['status' => 0]); } } public function status(Request $request) { if ($request->status != 1) { $count = Currency::where(['status' => 1])->count(); if ($count == 1) { return response()->json([ 'status' => 0, 'message' => translate('You_can_not_disable_all_currencies.') ]); } } $currency = Currency::find($request->id); $currency->status = $request->status; $currency->save(); return response()->json([ 'status' => 1, 'message' => translate('Currency_status_successfully_changed.') ]); } public function systemCurrencyUpdate(Request $request) { $business_settings = BusinessSetting::where('type', 'system_default_currency')->first(); $business_settings->value = $request['currency_id']; $business_settings->save(); $currency_model = Helpers::get_business_settings('currency_model'); if ($currency_model == 'multi_currency') { $default = Currency::find($request['currency_id']); foreach (Currency::all() as $data) { Currency::where(['id' => $data['id']])->update([ 'exchange_rate' => ($data['exchange_rate'] / $default['exchange_rate']), 'updated_at' => now() ]); } } Toastr::success(translate('System_Default_currency_updated_successfully')); return redirect()->back(); } }