public function decide(Request $request, Order $order)
 {
     $cancellation = $order->getCancellation();
     $this->authorize('decide', $cancellation);
     if (is_null($cancellation)) {
         return $this->error(OrderCancellation::CAN_NOT_FIND);
     }
     $approved = $request->input('approved') ?: false;
     DB::transaction(function () use($cancellation, $order, $approved) {
         $this->orderManager->decideCancellation($cancellation, $approved);
         if ($approved) {
             $this->orderManager->getOrderRepository()->cancel($order);
         }
     });
     return $this->success();
 }
 public function decide(Request $request, Order $order)
 {
     /** @var OrderRevision $orderRevision */
     if (!($orderRevision = $this->orderManager->getOrderRevisionRepository()->whereOrder($order)->first())) {
         return $this->error(OrderRevision::CAN_NOT_FIND);
     }
     $this->authorize('decide', $orderRevision);
     $approved = $request->input('approved') ?: false;
     // If rejected mark the revision as not approved and be done.
     if (!$approved) {
         $orderRevision->setApproved(false);
         $this->orderManager->getOrderRevisionRepository()->save($orderRevision);
         return $this->success('action');
     }
     // If accepted mark the revision as approved and update the order details.
     DB::transaction(function () use($order, $orderRevision, $approved) {
         $orderRevision->setApproved();
         $this->orderManager->getOrderRevisionRepository()->save($orderRevision);
         $this->orderManager->getOrderRepository()->update($order, $orderRevision->getChangesArray());
         event(new OrderRevisionEvent($orderRevision));
     });
     return $this->success('edit');
 }
 public function ship(Order $order)
 {
     $this->orderManager->getOrderRepository()->ship($order);
     return $this->success('edit');
 }