public function update(OrderUpdateRequest $request, Order $order) { $productsTotalChanged = $request->input('products_total') != $order->products_total; $shippingTotalChanged = $request->input('shipping_total') != $order->shipping_total; if (!$productsTotalChanged and !$shippingTotalChanged) { Flash::warning(trans('order::revision.no_change')); return back(); } DB::transaction(function () use($order, $request, $productsTotalChanged, $shippingTotalChanged) { $orderRevision = new OrderRevision(['products_total' => $productsTotalChanged ? $request->input('products_total') : null, 'shipping_total' => $shippingTotalChanged ? $request->input('shipping_total') : null]); $orderRevision->setPerformer($this->account()); $orderRevision->setReactor($order->getBuyer()); $order->revisions()->save($orderRevision); event(new OrderRevisionEvent($orderRevision)); }); Flash::success('订单修改已提交,等待买家同意'); return back(); }
protected function asUser(User $user = null) { return parent::asUser($user ?: ($this->order ? $this->order->getBuyer() : null)); }
public function isOrderBuyer(Order $order) { return $this->is($order->getBuyer()); }