【发布时间】:2022-11-17 20:24:18
【问题描述】:
我正在尝试获取过去 48 小时内至少有 2 个 cmet 的所有帖子。我正在使用以下代码:
$posts= Post::has( 'comments', '>', 1 )->whereHas( 'comments', function( $comments ) {
return $comments->where( 'created_at', '>', Carbon::now()->subDays(2) );
})->get()->toArray();
- 至少有 2 个 cmets 工作正常。
- 在过去 48 小时内不工作。
【问题讨论】: