/** * Bootstrap any application services. * * @return void */ public function boot() { // view()->composer('general.nav', function ($view) { $view->with('all_stores', Store::ordered()->get())->with('all_categories', Constants::availableCategories()); }); view()->composer('general.footer', function ($view) { $view->with('all_categories', Constants::availableCategories()); }); view()->composer('general.featured_offers', function ($view) { $view->with('featured_offers', Offer::featuredOffers()); }); view()->composer('general.featured_stores', function ($view) { $view->with('featured_stores', Store::featured()); }); }
public static function featuredOffers() { return Offer::join('categories', 'offers.category_id', '=', 'categories.id')->join('stores', 'stores.id', '=', 'categories.store_id')->select('stores.name as store', 'stores.image as store_image', 'categories.name as category', 'categories.cashback as cashback', 'offers.id as id', 'stores.slug as slug', 'offers.name as name', 'offers.link', 'offers.description as description', 'offers.expiry_date')->orderBy('stores.name', 'asc')->featured()->active(); }
public function store($slug) { $store = Store::slug($slug)->get()->first(); return view('store')->with('store', $store)->with('categories', $store->getCategories()->get())->with('offers', Offer::join('categories', 'offers.category_id', '=', 'categories.id')->join('stores', 'stores.id', '=', 'categories.store_id')->select('categories.name as category', 'categories.cashback as cashback', 'offers.id as id', 'stores.slug as slug', 'offers.name as name', 'offers.link', 'offers.description as description', 'offers.expiry_date')->where('slug', $slug)->orderBy('expiry_date', 'desc')->active())->with('expired_offers', Offer::join('categories', 'offers.category_id', '=', 'categories.id')->join('stores', 'stores.id', '=', 'categories.store_id')->select('categories.name as category', 'categories.cashback as cashback', 'offers.id as id', 'stores.slug as slug', 'offers.name as name', 'offers.link', 'offers.description as description', 'offers.expiry_date')->where('slug', $slug)->orderBy('expiry_date', 'desc')->expired()); }
public function get_category_offers($id) { $offers = Offer::join('categories', 'offers.category_id', '=', 'categories.id')->join('stores', 'stores.id', '=', 'categories.store_id')->where('category_id', $id)->orderBy('stores.name', 'asc')->paginate(25, ['stores.name as store', 'stores.image as store_image', 'categories.name as category', 'offers.id as id', 'offers.name as name', 'offers.link', 'offers.description as description', 'offers.featured as featured', 'offers.expiry_date']); return view('admin/offers/index')->with('offers', $offers); }