productRepo = $productRepository; } /** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function search() { if (request()->has('q') && request()->input('q') != '') { $list = $this->productRepo->searchProduct(request()->input('q')); } else { $list = $this->productRepo->listProducts(); } $products = $list->where('status', 1)->map(function (Product $item) { return $this->transformProduct($item); }); return view('front.products.product-search', [ 'products' => $this->productRepo->paginateArrayResults($products->all(), 10) ]); } /** * Get the product * * @param string $slug * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function show(string $slug) { $product = $this->productRepo->findProductBySlug(['slug' => $slug]); $images = $product->images()->get(); $category = $product->categories()->first(); $productAttributes = $product->attributes; return view('front.products.product', compact( 'product', 'images', 'productAttributes', 'category' )); } }