app/Http/Controllers/admin/DiscussController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index(Request $request)
    {
            $req = $request -> input('search','');
            $data = DB::table('jc_discuss as d')
                ->join('jc_goods as g','d.gid','=','g.id')
                ->join('jc_users as u','d.uid','=','u.id')
                ->where('g.name','like','%'.$req.'%')
                ->select('d.id','g.name','u.username','d.content')
                ->paginate(8)->appends($request->input());
            return view('admin.discuss.index',['title'=>'评论列表','data'=>$data,'req'=>$req]);
    }
public function index ( Request $ request ) { $ req = $ request -> input ( 'search' , '' ) ; $ data = DB :: table ( 'jc_discuss as d' ) -> join ( 'jc_goods as g' , 'd.gid' , '=' , 'g.id' ) -> join ( 'jc_users as u' , 'd.uid' , '=' , 'u.id' ) -> where ( 'g.name' , 'like' , '%' . $ req . '%' ) -> select ( 'd.id' , 'g.name' , 'u.username' , 'd.content' ) -> paginate ( 8 ) -> appends ( $ request -> input ( ) ) ; return view ( 'admin.discuss.index' , [ 'title' => '评论列表','data'= > $data, 'r e q'=> $ req]) ; }
Display a listing of the resource.
Display a listing of the resource .
// $req = $request -> has('search'); //获取需要搜索的数据 //获取列表需要的所有的数据 // dump($data); // $data1 = Goods::where('name','like','%'.$req.'%')->get(); // foreach ($data1 as $k => $v) // { //     $data = Discuss::where('gid','=',$v->id)->paginate(10); // } // return view('admin.discuss.index',['title'=>'评论列表','data'=>$data,'req'=>$req]);