Exemplo n.º 1
0
 function productDetailFront(Request $request, $slug, $id)
 {
     $product = Product::with(['subcategory', 'files', 'providers.user'])->find($id);
     $questions = $this->reloadQuestions($id);
     $featuresTranslate = $this->setFeaturesTranslate($product);
     $offer = false;
     return view('front.productDetail', compact('questions', 'product', 'featuresTranslate', 'offer'));
     /* Versión anterior al cambio de productos con muchos proveedores*/
     $product = Product::find($id);
     if ($product->isActive && $product->isValidate || $request->ajax()) {
         $offer = ($offerModel = $product->offers()->first()) ? Carbon::now()->between(new Carbon($offerModel->offer_on), new Carbon($offerModel->offer_off)) ? $offerModel->offer_price : null : null;
         //$description = $offerModel->offer_description;
         $questions = $this->reloadQuestions($id);
         $featuresTranslate = $this->setFeaturesTranslate($product);
         return view('front.productDetail', compact('questions', 'product', 'featuresTranslate', 'offer', 'description'));
     }
     return redirect()->route('home');
 }
Exemplo n.º 2
0
 function validateProduct($id)
 {
     $product = Product::find($id);
     if ($product->isValidate) {
         $product->update(['isValidate' => 0]);
     } else {
         $product->update(['isValidate' => 1, 'isActive' => 1]);
     }
     return redirect()->route('showUser', $product->user()->first()->id);
 }