We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
获取用户的订单时只获取最新的2条:
$dbprefix = config('database.connections.mysql.prefix'); $orderCount = 2; $users = User::with(['order' => function($q) use($dbprefix, $orderCount){ $q->select(['o.order_id','o.user_id','o.order_sn']) ->leftJoin('order as o', function($join){ $join->on('o.user_id', '=', 'order.user_id')->on('order.order_id', '>=', 'o.order_id'); }) ->groupBy('o.user_id') ->groupBy('o.order_id') ->having(DB::raw("count({$dbprefix}o.order_id)"), '<=', $orderCount); }])->limit(20)->get();
The text was updated successfully, but these errors were encountered:
No branches or pull requests
获取用户的订单时只获取最新的2条:
The text was updated successfully, but these errors were encountered: