Exemplo n.º 1
0
 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);
 }