当前位置: 首页>>代码示例>>PHP>>正文


PHP Cart::destroy方法代码示例

本文整理汇总了PHP中Cart::destroy方法的典型用法代码示例。如果您正苦于以下问题:PHP Cart::destroy方法的具体用法?PHP Cart::destroy怎么用?PHP Cart::destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cart的用法示例。


在下文中一共展示了Cart::destroy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: postAdd

 public function postAdd()
 {
     $rules = ['firstname' => 'required|min:2', 'lastname' => 'required|min:2', 'address' => 'required|min:5', 'phone' => 'required|min:7'];
     if (!Auth::check()) {
         array_push($rules, ['email' => 'required|email|unique:users']);
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to("checkout")->withErrors($validator)->withInput(Input::except(''));
     } else {
         if (Auth::check()) {
             $user = User::find(Auth::user()->id);
         } else {
             $user = new User();
             $user->email = Input::get('email');
             $password = str_random(10);
             $user->password = Hash::make($password);
         }
         $user->firstname = Input::get('firstname');
         $user->lastname = Input::get('lastname');
         $user->address = Input::get('address');
         $user->phone = Input::get('phone');
         if ($user->save()) {
             $role = Role::where('name', '=', 'Customer')->first();
             if (!$user->hasRole("Customer")) {
                 $user->roles()->attach($role->id);
             }
             $order = new Order();
             $order->user_id = $user->id;
             $order->status_id = OrderStatus::where('title', '=', 'Новый')->first()->id;
             $order->comment = 'Телефон: <b>' . $user->phone . '</b><br>Адрес: <b>' . $user->address . '</b><br>Комментарий покупателя: ' . '<i>' . Input::get('comment') . '</i>';
             if ($order->save()) {
                 $cart = Cart::content();
                 foreach ($cart as $product) {
                     $orderDetails = new OrderDetails();
                     $orderDetails->order_id = $order->id;
                     $orderDetails->product_id = $product->id;
                     $orderDetails->quantity = $product->qty;
                     $orderDetails->price = $product->price;
                     $orderDetails->save();
                 }
             }
             if (!Auth::check()) {
                 Mail::send('mail.registration', ['firstname' => $user->firstname, 'login' => $user->email, 'password' => $password, 'setting' => Config::get('setting')], function ($message) {
                     $message->to(Input::get('email'))->subject("Регистрация прошла успешно");
                 });
             }
             $orderId = $order->id;
             Mail::send('mail.order', ['cart' => $cart, 'order' => $order, 'phone' => $user->phone, 'user' => $user->firstname . ' ' . $user->lastname], function ($message) use($orderId) {
                 $message->to(Input::get('email'))->subject("Ваша заявка №{$orderId} принята");
             });
             Cart::destroy();
             return Redirect::to("checkout/thanks/spasibo-vash-zakaz-prinyat")->with('successcart', 'ok', ['cart' => $cart]);
         }
     }
 }
开发者ID:Rotron,项目名称:shop,代码行数:56,代码来源:CheckoutController.php

示例2: success

 public function success()
 {
     $result = Session::get('result');
     setlocale(LC_MONETARY, "en_US");
     $user = Auth::user();
     $fee = Cart::total() / getenv("SV_FEE") - Cart::total();
     $total = $fee + Cart::total();
     $param = array('report_type' => 'customer_vault', 'customer_vault_id' => $user->customer_id);
     $payment = new Payment();
     $vault = $payment->ask($param);
     $items = Cart::contents();
     // Clean the cart
     Cart::destroy();
     return View::make('pages.public.success')->with('page_title', 'Payment Complete')->withUser($user)->with('products', $items)->with('result', $result)->with('vault', $vault);
 }
开发者ID:illuminate3,项目名称:league-production,代码行数:15,代码来源:PaymentController.php

示例3: getReservation

 public function getReservation()
 {
     Cart::destroy();
     $role = Auth::user()->role;
     if ($role == 'hotel-admin') {
         $company_id_logged_user = Auth::user()->comp_id;
         DB::setFetchMode(PDO::FETCH_ASSOC);
         $data_room_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->select('hotel_rooms.room_code', 'hotel_rooms.branch_code', 'hotel_rooms.price_per_night', 'hotel_rooms.description', 'hotel_rooms.status', 'hotel_rooms.image', 'branch.branch_name', 'branch.address', 'branch.email', 'branch.city')->where('branch.company_id', '=', $company_id_logged_user)->where('hotel_rooms.status', '=', 'available')->get();
         //            dd($data_room_details);
     } elseif ($role == 'hotel-staff') {
         $staff_id = Auth::user()->id;
         DB::setFetchMode(PDO::FETCH_ASSOC);
         $owned_branch_code = DB::table('staff')->select('staff.branch')->where('person_id', '=', $staff_id)->first();
         $data_room_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->select('hotel_rooms.room_code', 'hotel_rooms.branch_code', 'hotel_rooms.price_per_night', 'hotel_rooms.description', 'hotel_rooms.status', 'hotel_rooms.image', 'branch.branch_name', 'branch.address', 'branch.email', 'branch.city')->where('branch.branch_code', '=', $owned_branch_code)->where('hotel_rooms.status', '=', 'available')->get();
         // dd($data_room_details);
     }
     return View::make('reservations.available-bookings', array('data' => $data_room_details));
 }
开发者ID:nimeshmora,项目名称:OCM-Travel-Bratts,代码行数:18,代码来源:ReservationController.php

示例4: checkout

 function checkout()
 {
     // process cart items
     if (count(Cart::contents()) < 1) {
         return Redirect::to('order');
     }
     $items = Cart::contents();
     $invoice_id = DB::table('invoices')->insertGetId(array('user_id' => Auth::user()->id, 'due_date' => date('Y-m-d'), 'status' => 'Unpaid'));
     foreach ($items as $item) {
         // to ensure the shopping cart was not manipulated, we use the option directly, not from the price
         $option = ServiceOption::find($item->id);
         // build description string
         $description = $option->service->name . ' ' . $option->name . ' recurring every ' . $item->quantity . ' month(s)';
         DB::table('invoice_items')->insert(array('invoice_id' => $invoice_id, 'description' => $description, 'unit_price' => $item->price));
     }
     // push invoice to e-mail queue
     // empty the cart
     Cart::destroy();
     return Redirect::to('order/thankyou');
 }
开发者ID:carriercomm,项目名称:saaspanel,代码行数:20,代码来源:OrderController.php

示例5: borrar

 public static function borrar()
 {
     $respuesta = array();
     $input = array();
     $reglas = array('id' => array('integer'));
     $validator = Validator::make($input, $reglas);
     if ($validator->fails()) {
         $respuesta['mensaje'] = $validator;
         $respuesta['error'] = true;
     } else {
         $carrito = Carrito::find(Session::get('carrito'));
         //$carrito->fecha_baja = date("Y-m-d H:i:s");
         $carrito->estado = 'B';
         //$archivo->usuario_id_baja = Auth::user()->id;
         $carrito->save();
         Cart::destroy();
         Session::forget('carrito');
         $respuesta['mensaje'] = 'Carrito eliminado.';
         $respuesta['error'] = false;
         $respuesta['data'] = $carrito;
     }
     return $respuesta;
 }
开发者ID:tatu-carreta,项目名称:mariasanti_v2,代码行数:23,代码来源:Pedido.php

示例6: process

 public function process()
 {
     $factura = new Factura();
     $factura->usuario_id = Auth::user()->id;
     $factura->total = Cart::total();
     foreach (Cart::content() as $item) {
         if (Item::find($item['id'])->stock == 0) {
             Session::flash('error', 'El item ' . $item['name'] . ' se ha agotado');
             return Redirect::back();
         }
         if (Item::find($item['id'])->stock - $item['qty'] < 0) {
             Session::flash('error', 'No hay suficiente stock del item ' . $item['name'] . ' para cubrir su pedido');
             return Redirect::back();
         }
     }
     if ($factura->save()) {
         foreach (Cart::content() as $item) {
             $detalle = new Detalle();
             $detalle->factura_id = $factura->id;
             $detalle->item_id = $item['id'];
             $detalle->cantidad = $item['qty'];
             if ($detalle->save()) {
                 $deduct = Item::find($item['id']);
                 $deduct->stock -= $item['qty'];
                 $deduct->save();
             } else {
                 Session::flash('error', 'Error al procesar');
                 return Redirect::back();
             }
         }
     } else {
         Session::flash('error', 'Error al procesar');
         return Redirect::back();
     }
     Cart::destroy();
     return Redirect::to('shop');
 }
开发者ID:Rubenazo,项目名称:belleza,代码行数:37,代码来源:ShoppingController.php

示例7: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $carts = Cart::content();
     if (Cart::count() < 1) {
         Session::flash('flash_error', 'You need add at least one product!');
     }
     $order = new Order();
     $order->user_id = Auth::user()->id;
     $order->date = date('Y-m-d h:i:s');
     $order->total = money_format('%.2n', Cart::total());
     $order->save();
     foreach ($carts as $row) {
         $product = Product::find($row->id)->firstOrFail();
         $orderDetail = new OrderDetail();
         $orderDetail->order_id = $order->id;
         $orderDetail->product_id = $product->code;
         $orderDetail->quantity = $row->qty;
         $orderDetail->sub_total = money_format('%.2n', $row->subtotal);
         $orderDetail->save();
         Cart::destroy();
     }
     Session::flash('message', 'Successfully created order!');
     return Redirect::to('orders');
 }
开发者ID:elioth010,项目名称:carretilla_online,代码行数:29,代码来源:OrderController.php

示例8: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $startDate = Carbon::now();
     $from = Carbon::now()->hour(0)->minute(0)->second(0);
     $to = Carbon::now()->hour(23)->minute(59)->second(59);
     $schedules = SchedulePayment::where('status', 0)->whereBetween('date', array($from, $to))->with('member.user.profile')->get();
     //$schedules = SchedulePayment::where('status', 0)->with('member.user.profile')->get();
     $errors = array();
     $totalAmount = array();
     $errorAmount = array();
     //save daylog
     $dayLog = new ScheduleDailyLog();
     $dayLog->started_on = Carbon::now()->toDateTimeString();
     $dayLog->payments_count = count($schedules);
     $dayLog->save();
     Cart::destroy();
     foreach ($schedules as $schedule) {
         try {
             $vault = $schedule->member->user->profile->customer_vault;
             $user = User::find($schedule->member->user->id);
             $player = Player::find($schedule->member->player->id);
             $club = Club::find($schedule->club_id);
             $team = Team::find($schedule->member->team_id);
             $uuid = Uuid::generate();
             $member = Member::find($schedule->member->id);
             $history = SchedulePayment::find($schedule->id);
             //manually login user out before login new user
             Auth::logout();
             //manually login user
             Auth::login($user);
             //clear cart content
             Cart::destroy();
             //set cart item
             $itemCart = array('id' => $team->id, 'name' => "Scheduled payment for " . $team->name, 'price' => $schedule->subtotal, 'quantity' => 1, 'organization' => $club->name, 'organization_id' => $club->id, 'player_id' => $player->id, 'user_id' => $user->id, 'type' => 'full', 'autopay' => true);
             Cart::insert($itemCart);
             //check if vault exist
             if ($vault) {
                 $param = array('customer_vault_id' => $vault, 'discount' => null, 'club' => $club->id);
                 $payment = new Payment();
                 $transaction = $payment->sale($param);
                 //temp json_decode(json_encode($array), FALSE);
                 //$transaction = json_decode(json_encode(array('response' => 1, 'total'=>$schedule->total, 'fee'=>$schedule->fee)), FALSE);
                 if ($transaction->response == 3 || $transaction->response == 2) {
                     $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => $transaction->transactionid . ' : ' . $transaction->responsetext, 'error_amount' => $schedule->total, 'daily_log_id' => $dayLog->id);
                     array_push($errorAmount, number_format($schedule->total, 2));
                     //Email error
                     $emailerrorstatus = $payment->error($transaction, $club->id, $player->id);
                 } else {
                     array_push($totalAmount, number_format($transaction->total, 2));
                     $payment->id = $uuid;
                     $payment->customer = $vault;
                     $payment->transaction = $transaction->transactionid;
                     $payment->subtotal = $transaction->subtotal;
                     $payment->service_fee = $transaction->fee;
                     $payment->total = $transaction->total;
                     $payment->promo = $transaction->promo;
                     $payment->tax = $transaction->tax;
                     $payment->discount = $transaction->discount;
                     $payment->club_id = $club->id;
                     $payment->user_id = $user->id;
                     $payment->player_id = $player->id;
                     $payment->event_type = null;
                     $payment->type = $transaction->type;
                     $payment->save();
                     //Email receipt
                     $payment->receipt($transaction, $club->id, $player->id);
                     $sale = new Item();
                     $sale->description = $itemCart['name'];
                     $sale->quantity = $itemCart['quantity'];
                     $sale->price = $itemCart['price'];
                     $sale->fee = $transaction->fee;
                     $sale->member_id = $member->id;
                     $sale->team_id = $team->id;
                     $sale->payment_id = $uuid;
                     $sale->save();
                     //update schedule
                     $history->status = 2;
                     $history->save();
                 }
             } else {
                 //save error that vault didnt exist
                 $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => 'Customer Vault not found', 'error_amount' => number_format($schedule->total, 2), 'daily_log_id' => $dayLog->id);
                 array_push($errorAmount, number_format($schedule->total, 2));
             }
         } catch (Exception $e) {
             //save internal error
             $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => $e, 'error_amount' => number_format($schedule->total, 2), 'daily_log_id' => $dayLog->id);
             array_push($errorAmount, number_format($schedule->total, 2));
         }
     }
     //end of foreach schedule
     //save log for everything done
     $dayLogEnd = ScheduleDailyLog::find($dayLog->id);
     $dayLogEnd->ended_on = Carbon::now()->toDateTimeString();
     $dayLogEnd->successful_count = Count($totalAmount);
//.........这里部分代码省略.........
开发者ID:illuminate3,项目名称:league-production,代码行数:101,代码来源:PlanSchedule.php

示例9: destroy

 /**
  * Remove the specified cart from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Cart::destroy($id);
     return Redirect::route('carts.index');
 }
开发者ID:NocturnalWare,项目名称:managedotband,代码行数:11,代码来源:CartsController.php

示例10: getSignOut

 public function getSignOut()
 {
     Auth::logout();
     Cart::destroy();
     return Redirect::route('login-page');
 }
开发者ID:nimeshmora,项目名称:OCM-Travel-Bratts,代码行数:6,代码来源:AccountController.php

示例11: postPurchaseAndNewDir

 public function postPurchaseAndNewDir()
 {
     if (Cart::count() < 1) {
         Session::flash('danger', 'Error, no posee articulos en el carrito');
         return Redirect::back();
     }
     $input = Input::all();
     $rules = array('email' => 'required|email', 'dir' => 'required');
     $msg = array('required' => 'Campo requerido', 'email' => 'El campo debe ser un email');
     $validator = Validator::make($input, $rules, $msg);
     if ($validator->fails()) {
         Redirect::back()->withError($validator)->withInput();
     }
     $dir = new Dir();
     $dir->user_id = Auth::user()->id;
     $dir->email = $input['email'];
     $dir->dir = $input['dir'];
     if ($dir->save()) {
         $fac = new Facturas();
         $fac->user_id = Auth::user()->id;
         $fac->dir = $dir->id;
         if ($fac->save()) {
             foreach (Cart::content() as $c) {
                 $misc = Misc::find($c->options['misc']);
                 $misc->item_stock = $misc->item_stock - $c->qty;
                 $misc->save();
                 $itemFac = new FacturaItem();
                 $itemFac->factura_id = $fac->id;
                 $itemFac->item_id = $c->id;
                 $itemFac->item_qty = $c->qty;
                 $itemFac->item_talla = $c->options['talla'];
                 $itemFac->item_color = $c->options['color'];
                 $itemFac->item_precio = $c->price;
                 $itemFac->save();
             }
             Cart::destroy();
             return Redirect::to('compra/procesar/' . $fac->id);
         }
     }
 }
开发者ID:bakuryuthem0,项目名称:nia,代码行数:40,代码来源:ItemController.php

示例12: agregarPedido

 public function agregarPedido()
 {
     $input = Input::all();
     Input::flashOnly('nombre', 'email', 'empresa', 'telefono', 'consulta');
     $reglas = array('email' => array('required', 'email'), 'nombre' => array('required'), 'telefono' => array('required'));
     $validator = Validator::make($input, $reglas);
     if ($validator->fails()) {
         $messages = $validator->messages();
         if ($messages->has('nombre')) {
             $mensaje = $messages->first('nombre');
         } elseif ($messages->has('email')) {
             $mensaje = $messages->first('email');
         } elseif ($messages->has('telefono')) {
             $mensaje = $messages->first('telefono');
         } else {
             $mensaje = Lang::get('controllers.pedido.datos_consulta_contacto_incorrectos');
         }
         return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true)->withInput();
     } else {
         $productos = array();
         if (Session::has('carrito')) {
             $carrito_id = Session::get('carrito');
             $carrito = Carrito::find($carrito_id);
             $datos = DB::table('carrito_producto')->where('carrito_id', $carrito->id)->where('estado', 'A')->get();
             foreach ($datos as $prod) {
                 $data = array('id' => $prod->producto_id, 'cantidad' => $prod->cantidad, 'precio' => $prod->precio);
                 array_push($productos, $data);
             }
         }
         if (count($productos) == 0) {
             $mensaje = Lang::get('controllers.pedido.debe_tener_producto');
             return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true)->withInput();
         } else {
             //Levanto los datos del formulario del presupuesto para
             //generar la persona correspondiente al pedido
             $datos_persona = array('email' => Input::get('email'), 'apellido' => Input::get('nombre'), 'nombre' => Input::get('empresa'), 'tipo_telefono_id' => 2, 'telefono' => Input::get('telefono'));
             $persona = Persona::agregar($datos_persona);
             if ($persona['error']) {
                 $mensaje = Lang::get('controllers.pedido.error_realizar_pedido');
                 return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true);
             } else {
                 $datos_pedido = array('persona_id' => $persona['data']->id, 'productos' => $productos);
                 $respuesta = Pedido::agregar($datos_pedido);
                 if ($respuesta['error']) {
                     return Redirect::to('/carrito')->with('mensaje', $respuesta['mensaje'])->with('error', true);
                 } else {
                     $datos_resumen_pedido = array('persona_id' => $persona['data']->id, 'productos' => $productos, 'email' => Input::get('email'), 'nombre' => Input::get('nombre'), 'telefono' => Input::get('telefono'), 'empresa' => Input::get('empresa'), 'consulta' => Input::get('consulta'));
                     $envio_mail = $this->resumenPedido($datos_resumen_pedido);
                     if ($envio_mail) {
                         Cart::destroy();
                         Session::forget('carrito');
                         $mensaje = Lang::get('controllers.pedido.presupuesto_enviado');
                         return Redirect::to('/')->with('mensaje', $mensaje)->with('ok', true);
                     } else {
                         $mensaje = Lang::get('controllers.pedido.presupuesto_no_enviado');
                         return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true);
                     }
                 }
             }
         }
     }
 }
开发者ID:tatu-carreta,项目名称:mariasanti_v2,代码行数:62,代码来源:PedidoController.php

示例13: saveGaji

 public function saveGaji()
 {
     $cart = Cart::content();
     foreach ($cart as $row) {
         $mg02 = new mg02();
         $mg02->mk01_id = $row->options['idkaryawan'];
         $mg02->mg01_id = $row->name;
         $mg02->nilgj = $row->price;
         $mg02->save();
     }
     Cart::destroy();
     return Redirect::to("master/karyawan");
 }
开发者ID:ocreatagit,项目名称:absensi_indografika,代码行数:13,代码来源:MasterKaryawanController.php

示例14: paymentRemoveCartItem

 public function paymentRemoveCartItem($id)
 {
     Cart::destroy();
     return Redirect::action('PlayerController@index');
 }
开发者ID:illuminate3,项目名称:league-production,代码行数:5,代码来源:ParticipantController.php

示例15: logout

 /**
  * Perform user logout.
  */
 public function logout()
 {
     Cart::destroy();
     Auth::logout();
     return Redirect::to('');
 }
开发者ID:crowdtruth,项目名称:crowdtruth,代码行数:9,代码来源:UserController.php


注:本文中的Cart::destroy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。