/**
  * Handle the command.
  *
  * @param  SaveOrderCommand  $command
  * @return void
  */
 public function handle(SaveOrderCommand $command)
 {
     $this->orderRepository->save($command->input);
     $lastOrderId = $this->orderRepository->findLastSavedId();
     foreach ($command->orderItems as $id => $amount) {
         $orderItemName = $this->productRepository->findById($id)->name;
         $this->orderItemRepository->save($orderItemName, $amount, $lastOrderId);
     }
     $order = $this->orderRepository->findById($lastOrderId);
     Mail::send('emails.orderinfo', ['order' => $order], function ($m) use($order) {
         $m->to($order->email, $order->billing_name)->subject('Your Order Information');
     });
 }
Ejemplo n.º 2
0
 public function destroy($id)
 {
     $this->orderRepository->findById($id)->delete();
     return redirect()->back();
 }