/** * 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); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // $categories = Category::join('stores', 'stores.id', '=', 'categories.store_id')->orderBy('stores.name')->paginate(25, array('stores.image', 'categories.cashback', 'categories.name', 'categories.id')); return view('admin.categories.index')->with('categories', $categories); }