product = $product; $this->flyer = $flyer; $this->offer = $offer; $this->shop = $shop; $this->category = $category; } /** * Returns count of deal. * * @param array $filter * * @return int */ public function count() { return 0; } /** * Make gadget View * * @param string $view * * @param int $count * * @return View */ public function gadget($view = 'admin.product.gadget', $count = 10) { if (User::hasRole('user')) { $this->product->pushCriteria(new \Litepie\Deal\Repositories\Criteria\ProductUserCriteria()); } $product = $this->product->scopeQuery(function ($query) use ($count) { return $query->orderBy('id', 'DESC')->take($count); })->all(); return view('deal::' . $view, compact('product'))->render(); } /** * Make gadget View * * @param string $view * * @param int $count * * @return View */ public function gadget($view = 'admin.flyer.gadget', $count = 10) { if (User::hasRole('user')) { $this->flyer->pushCriteria(new \Litepie\Deal\Repositories\Criteria\FlyerUserCriteria()); } $flyer = $this->flyer->scopeQuery(function ($query) use ($count) { return $query->orderBy('id', 'DESC')->take($count); })->all(); return view('deal::' . $view, compact('flyer'))->render(); } /** * Make gadget View * * @param string $view * * @param int $count * * @return View */ public function gadget($view = 'admin.offer.gadget', $count = 10) { if (User::hasRole('user')) { $this->offer->pushCriteria(new \Litepie\Deal\Repositories\Criteria\OfferUserCriteria()); } $offer = $this->offer->scopeQuery(function ($query) use ($count) { return $query->orderBy('id', 'DESC')->take($count); })->all(); return view('deal::' . $view, compact('offer'))->render(); } /** * Make gadget View * * @param string $view * * @param int $count * * @return View */ public function gadget($view = 'admin.shop.gadget', $count = 10) { if (User::hasRole('user')) { $this->shop->pushCriteria(new \Litepie\Deal\Repositories\Criteria\ShopUserCriteria()); } $shop = $this->shop->scopeQuery(function ($query) use ($count) { return $query->orderBy('id', 'DESC')->take($count); })->all(); return view('deal::' . $view, compact('shop'))->render(); } /** * Make gadget View * * @param string $view * * @param int $count * * @return View */ public function gadget($view = 'admin.category.gadget', $count = 10) { if (User::hasRole('user')) { $this->category->pushCriteria(new \Litepie\Deal\Repositories\Criteria\CategoryUserCriteria()); } $category = $this->category->scopeQuery(function ($query) use ($count) { return $query->orderBy('id', 'DESC')->take($count); })->all(); return view('deal::' . $view, compact('category'))->render(); } }