public function sendOrder($order_id)
{
$user = \Auth::user();
$order = Order::where('id', $order_id)->where('seller_id', $user->id)->ofStatus('pending')->select('id', 'user_id', 'status', 'seller_id')->first();
//checks if the orders is sold by the user and if it is on open status
if ($order) {
//Mails and notifications are now sent in the save method for the order
$order->status = 'sent';
$order->save();
Notice::create(['user_id' => $order->user_id, 'sender_id' => $order->seller_id, 'action_type_id' => 11, 'source_id' => $order->id, 'status' => 'new']);
$order_content = OrderDetail::where('order_id', $order->id)->get();
$band = false;
foreach ($order_content as $row) {
if ($row->product->type != 'item') {
$band = $this->deliveryVirtualProduct($order->id, $row->product_id, new Request(), false);
$band = $band === 'closed' ? true : false;
}
}
Session::push('message', trans('store.orders_index.order_sent') . ' (#' . $order->id . ')' . (!$band ? '' : trans('store.order_closed_message')));
return redirect(route('orders.pendingOrders'));
} else {
return redirect(route('orders.pendingOrders'));
}
}