app/Http/Controllers/admin/GoodsController.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)
    {   
        $count = DB::table('jc_goods')->whereNull('deleted_at')->count();
        $search = $request->input('search','');
        $gcid = $request->input('gcid','');
        if(empty($gcid)){
             $goods = Goods::where('name','like','%'.$search.'%')
                    ->paginate(8)
                    ->appends($request->input());
        }else{
            $goods = Goods::where('name','like','%'.$search.'%')
                    ->where('gcid',$gcid)
                    ->paginate(8)
                    ->appends($request->input());
        }
        return view('admin.goods.index',['title'=>'商品列表','data'=>$goods,'cates'=>self::getcates(),'count'=>$count]);
    }
public function index ( Request $ request ) { $ count = DB :: table ( 'jc_goods' ) -> whereNull ( 'deleted_at' ) -> count ( ) ; $ search = $ request -> input ( 'search' , '' ) ; $ gcid = $ request -> input ( 'gcid' , '' ) ; if ( empty ( $ gcid ) ) { $ goods = Goods :: where ( 'name' , 'like' , '%' . $ search . '%' ) -> paginate ( 8 ) -> appends ( $ request -> input ( ) ) ; } else { $ goods = Goods :: where ( 'name' , 'like' , '%' . $ search . '%' ) -> where ( 'gcid' , $ gcid ) -> paginate ( 8 ) -> appends ( $ request -> input ( ) ) ; } return view ( 'admin.goods.index' , [ 'title' => '商品列表','data'= > $goods ,' c ates' = >self:: ge tcat es (),'coun t ' = >$count ]) ; }
Display a listing of the resource.
Display a listing of the resource .
//设置计算数据表中所有信息的数量