/** * 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()); }); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // $stores = Store::ordered()->paginate(25); return view('admin.stores.index')->with('stores', $stores); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { $category = Category::find($id); return view('admin.categories.edit')->with('stores', Store::ordered()->get())->with('current_store', $category->getStore())->with('all_categories', Constants::availableCategories())->with('category', $category); }
public function stores() { return view('stores')->with('stores', Store::ordered()->get()); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function edit($id) { // $offer = Offer::find($id); $categories = Category::join('stores', 'stores.id', '=', 'categories.store_id')->select(['stores.name as store_name', 'categories.name', 'categories.id'])->orderBy('stores.name', 'asc')->orderBy('categories.name', 'asc')->get(); $stores = Store::ordered()->get(); $values = []; foreach ($stores as $store) { $cats = []; foreach ($categories as $category) { if (strcmp($category['store_name'], $store['name']) == 0) { $cats[] = array('id' => $category['id'], 'name' => $category['name']); } } $values[$store['name']] = $cats; } return view('admin.offers.edit')->with('categories', $values)->with('category_id', $offer->category_id)->with('store_name', Category::find($offer->category_id)->getStore()->name)->with('offer', $offer); }