示例#1
0
 public function create()
 {
     $name = $_POST['name'];
     $code = $_POST['code'];
     $disc = $_POST['disc'];
     $maxdisc = $_POST['maxdisc'];
     $beginDate = $_POST['beginDate'];
     $endDate = $_POST['endDate'];
     try {
         $voucher = ['name' => $name, 'code' => $code, 'discount' => $disc, 'maxDiscount' => $maxdisc, 'beginDate' => $beginDate, 'endDate' => $endDate];
         if ($voc = Option::where('meta_key', 'voucher')->first()) {
             $unserialize = unserialize($voc->meta_value);
             $sum_array = array_push($unserialize, $voucher);
             $serialize = serialize($unserialize);
             $total = Option::where('meta_key', 'voucher')->update(['meta_value' => $serialize]);
             return redirect('master/setting/coupon')->with('success', 'Code Voucher berhasil ditambahkan');
         } else {
             $voc = new Option();
             $voc->meta_key = "voucher";
             $voc->meta_value = serialize(array($voucher));
             $voc->save();
             return redirect('master/setting/coupon')->with('success', 'Code Voucher berhasil ditambahkan');
         }
     } catch (Exception $e) {
         return 'error';
     }
 }
 public function add_bank_account(Request $request)
 {
     $rules = array('bank_name' => 'required', 'bank_account' => 'required', 'account_name' => 'required');
     $validator = Validator::make($request->all(), $rules);
     if (!$validator->fails()) {
         $bank_account = ['bank_name' => $request->bank_name, 'bank_account' => $request->bank_account, 'account_name' => $request->account_name];
         if ($bank = Option::where('meta_key', 'bank_account')->first()) {
             $unserialize = unserialize($bank->meta_value);
             $sum_array = array_push($unserialize, $bank_account);
             $serialize = serialize($unserialize);
             $total = Option::where('meta_key', 'bank_account')->update(['meta_value' => $serialize]);
             return redirect('master/setting/bank_account')->with('success', 'Nomor Rekening berhasil ditambahkan');
         } else {
             $bank = new Option();
             $bank->meta_key = "bank_account";
             $bank->meta_value = serialize(array($bank_account));
             $bank->save();
             return redirect('master/setting/bank_account')->with('success', 'Nomor Rekening berhasil ditambahkan');
         }
     } else {
         return redirect('master/setting/bank_account')->with('failed', 'Silahkan isi sesuai form ang disediakan');
     }
 }