/** * Toggle the active column on the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function toggle($id) { $productVariant = Product_variant::find($id); $productVariant->active = $productVariant->active ? 0 : 1; return $productVariant->save() ? response()->json(['success' => true, 'active' => $productVariant->active]) : response()->json(['success' => false], 422); }