示例#1
0
 public function proceedCheckOut(Request $request)
 {
     $user = Auth::user();
     $validator = Validator::make($request->all(), ['billing_address' => 'integer|exists:addresses,id', 'shipping_address' => 'required|integer|exists:addresses,id']);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator);
     } else {
         $wishedProducts = $user->userable->wishedProducts;
         if (count($wishedProducts) > 0) {
             foreach ($wishedProducts as $wishedProduct) {
                 if (CheckOut::create(['product_id' => $wishedProduct->product->id, 'customer_id' => $user->id, 'description' => $wishedProduct->product->description, 'customer_email' => $user->email, 'product_title' => $wishedProduct->product->title, 'product_price' => $wishedProduct->product->price, 'payment_id' => null, 'image' => $wishedProduct->product->image, 'current_unit' => $wishedProduct->product->currency_unit_id, 'supplier_id' => $wishedProduct->product->supplier_id, 'count' => $wishedProduct->count, 'receiver_address_id' => $request->input('shipping_address'), 'bill_address_id' => $request->has('billing_address') ? $request->input('billing_address') : null])) {
                     $wishedProduct->delete();
                 }
             }
             return redirect()->action('Dashboard\\CustomerController@showUnpaidOrders');
         } else {
             return redirect()->back()->withErrors(['messages' => ['Lütfen sepetinize ürün ekleyiniz']]);
         }
     }
 }
示例#2
0
 public function submitPayment(Request $request)
 {
     $validator = Validator::make($request->all(), ['payment_option' => 'required|integer|exists:payment_infos,id']);
     if ($validator->fails()) {
         // get the error messages from the validator
         $messages = $validator->messages();
         // redirect our user back to the form with the errors from the validator
         return back()->withInput()->withErrors($messages);
     } else {
         $payment = new Payment();
         $payment->text = $request->input('note');
         $payment->payment_info_id = $request->input('payment_option');
         $payment->save();
         foreach ($request->input('checkouts') as $checkOutID) {
             $checkOut = CheckOut::where(['id' => $checkOutID, 'customer_id' => Auth::user()->id, 'payment_id' => null])->first();
             $checkOut->payment_id = $payment->id;
             $checkOut->update();
         }
         return redirect()->action('Dashboard\\CustomerController@showUnpaidOrders')->with(['success' => ['Odeme kaydı oluşturuldu']]);
     }
 }
示例#3
0
 public function confirmPayment(Request $request, $id)
 {
     $payment = Payment::find($id);
     $payment->does_supplier_confirm = 1;
     $payment->update();
     $checkouts = CheckOut::where(['supplier_id' => Auth::user()->id, 'payment_id' => $id])->get();
     foreach ($checkouts as $checkout) {
         $checkout->confirmed_by_supplier = 1;
         $checkout->update();
     }
     return redirect()->action('Dashboard\\SupplierController@showWaitingPayments')->with(['success' => ['Müşteri ödemesi onaylandı.']]);
 }