/** * @param Request $request * @param Product $product * @return \Illuminate\Http\RedirectResponse */ public function update(Request $request, Product $product) { // if a plan is selected authorize first if ($planId = $request->input('plan')) { $plan = $this->shippingPlanRepository->find($planId); $this->authorize('update', $plan); $product->shippingPlans()->sync([$planId]); } else { $product->shippingPlans()->sync([]); } return $this->success('edit'); }