public static function getAllCategories()
 {
     $data = Category::join('users', function ($join) {
         $join->on('category.user_id', '=', 'users.id');
     })->select('category.id', 'title', 'description', 'image_title', 'name')->orderBy('category.id', 'desc')->paginate(50);
     return $data;
 }
Example #2
0
 /**
  * Display the list of coupons from specific category.
  *
  * @param  string  $categoryName
  * @return \Illuminate\Http\Response
  */
 public function showCategory($id)
 {
     $coupons = Category::join('coupons', 'coupons.category_id', '=', 'categories.id')->where('categories.id', $id)->get();
     $category = Category::find($id);
     return view('coupon.list')->with('coupons', $coupons)->with('category', $category);
 }