public function productDetail($sex, $classify, $id) { $product = Product::find($id); $products = Product::where('deleted_at', '=', null)->where('id', '<>', $id)->where('sex', '=', $sex)->where('classify', '=', $classify)->paginate(9); $context = ['product' => $product, 'products' => $products]; return view('front.shop.Detail', $context); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { // Start transaction! \DB::beginTransaction(); try { $product = Product::find($id); if ($product) { $this->withdraw($product); //Product_I10n $productI10ns = Product_I10N::where('i18n_id', '=', $id)->get(); if ($productI10ns) { foreach ($productI10ns as $productI10n) { $this->withdraw($productI10n); } } // Commit \DB::commit(); return Response::json(['result' => 'OK']); } } catch (\ValidationException $e) { // Rollback and then redirect DB::rollback(); App::abort(404); } // Rollback DB::rollback(); }
/** * Remove the specified resource from storage. * * @param int $id * * @return \Illuminate\Http\Response */ public function destroy($id) { $product = Product::find($id); if ($product) { if ($product->delete()) { return response()->json(true); } } return response()->json('informatia nu s-a putut sterge', 500); }