📜  laravel withcount - PHP 代码示例

📅  最后修改于: 2022-03-11 14:54:35.037000             🧑  作者: Mango

代码示例1
$posts = App\Post::withCount('comments')->get();

foreach ($posts as $post) {
    echo $post->comments_count;
}