예제 #1
0
 public function history()
 {
     $history = History::all();
     $customers = Customer::all();
     return view('admin.history', compact('history', 'customers'));
 }
 public function showHistoryAdmin()
 {
     $history = History::all()->sortByDesc('command_at');
     $totalcommand = History::TotalOrder();
     return view('admin.history', compact('history', 'totalcommand'));
 }
 public function productHistoric()
 {
     $histories = History::all();
     return view('admin.historic', compact('histories'));
 }
예제 #4
0
 /**
  * Save the orders in storage
  */
 public function confirmCart()
 {
     $user_id = Auth::user()->id;
     $user = User::find($user_id);
     $customer = $user->customer;
     if ($customer == null) {
         return redirect('customer');
     } else {
         $command_id = History::all()->max('command_id');
         $command_id++;
         if (Session::has('cart')) {
             $cart = Session::get('cart');
             foreach ($cart as $id => $quantity) {
                 $product = Product::find($id);
                 $command = ['command_id' => $command_id, 'product_id' => $id, 'customer_id' => $customer->id, 'price' => $product->price * $quantity, 'quantity' => (int) $quantity, 'command_at' => date('Y-m-d H:i:s'), 'status' => 'unfinalized'];
                 History::create($command);
                 $product->score++;
                 $product->quantity -= $quantity;
                 $product->save();
             }
         }
         Session::forget('cart');
         $customer->increment('number_command');
         return redirect('/')->with(['message' => trans('app.finishSuccess'), 'alert' => 'success']);
     }
 }