$where = 'where `gid`='.$gid.' and `aid`='.$aid;
$key = trim($key) ? trim($key) : '';
if ($key) {
$where = $where . " and (`name` like '%".$key."%')";
}
$types = $request->input('types');
if (!empty($types)) {
$where = $where . ' and `types`='.$types;
}
$sql = '(SELECT * FROM `goods` '.$where.') as cc';//作为整体代入DB::raw
$list = DB::table(DB::raw($sql))->paginate(6);