遗漏翻译。
cool8jay
5年前
修改理由:
相关信息:
- 类型:文档文章
- 文章: 模型关联
- 文档: 《Laravel 5.7 中文文档(5.7)》
此投稿已在 5年前 合并。
内容修改:
Old | New | Differences |
---|---|---|
865 | 865 | |
866 | 866 | echo $posts[0]->pending_comments_count; |
867 | 867 | ``` |
868 | ||
869 | 如果你需要同时使用 `select` 和 `withCount` ,一定要确保在 `select` 之后调用 `withCount` : | |
870 | ``` | |
871 | $query = App\Post::select(['title', 'body'])->withCount('comments'); | |
872 | ||
873 | echo $posts[0]->title; | |
874 | echo $posts[0]->body; | |
875 | echo $posts[0]->comments_count; | |
876 | ``` | |
877 | ||
868 | 878 | <a name="eager-loading"></a> |
869 | 879 | ## 预加载 |
870 | 880 | … | … |
889 | 899 | } |
890 | 900 | ``` |
891 | 901 | |
892 | 现在,让我 | |
902 | 现在,让我们读取作者: | |
893 | 903 | |
894 | 904 | ```php |
895 | 905 | $books = App\Book::all(); |