App\Http\Controllers\OrdersController::startOrder PHP Method

startOrder() public method

Changes the status of an order to pending, so the process can start.
public startOrder ( $order_id )
    public function startOrder($order_id)
    {
        $user = \Auth::user();
        $order = Order::where('id', $order_id)->where('seller_id', $user->id)->ofStatus('open')->select('id', 'status', 'user_id', '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 = 'pending';
            $order->save();
            Notice::create(['user_id' => $order->user_id, 'sender_id' => $order->seller_id, 'action_type_id' => 15, 'source_id' => $order->id, 'status' => 'new']);
            Session::push('message', trans('store.orders_index.order_started') . ' (#' . $order->id . ')');
            return redirect(route('orders.pendingOrders'));
        } else {
            return redirect(route('orders.pendingOrders'));
        }
    }