share('app_title', '会员商城'); } public function index(Request $request) { $title = $request->title; $adverts = Advert::where('channel', 'member')->orderBy('sort', 'asc')->take(5)->get(); //banner $c_lists = Category::where('type', 'goods')->where('parent_id', 0)->orderBy('order', 'asc')->take(4)->get(); $lists = Goods::where('status', 1) ->when($title, function ($q) use ($title) { $q->where('title', 'like', "%{$title}%"); }) ->where('type', 'member') ->where('is_hot_sell', 1) ->orderBy('sort', 'asc') ->orderBy('created_at', 'desc') ->paginate(10); return view('index.index', compact('c_lists', 'adverts', 'lists', 'title')); } public function more(Request $request) { $category_id = $request->category; $title = $request->title; $lists = Goods::where('status', 1) ->when($title, function ($q) use ($title) { $q->where('title', 'like', "%{$title}%"); }) ->where('type', 'member') ->where('is_hot_sell', 1) ->orderBy('sort', 'asc') ->orderBy('created_at', 'desc') ->paginate(10); if ($lists->isNotEmpty()) { $html = response(view('index.more', compact('lists')))->getContent(); return $this->success($html); } else { return $this->error('没有数据了'); } } }