teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

修正

2020/11/11 12:56

投稿

renren643
renren643

スコア279

title CHANGED
File without changes
body CHANGED
@@ -22,6 +22,7 @@
22
22
  return $posts->get();
23
23
  }
24
24
  ```
25
+
25
26
  このメソッドは
26
27
  このように呼び出すことで
27
28
 
@@ -32,7 +33,14 @@
32
33
  投稿とそれに紐づくコメントを取得し、ページネーションの形式で渡してくれます
33
34
  また、このように呼び出すことで
34
35
 
36
+
35
37
  ```
38
+ $this->getPosts(['user'], true);
39
+ ```
40
+ postしたユーザーを一緒に取得でき、
41
+ また以下で
42
+
43
+ ```
36
44
  $this->getPosts();
37
45
  ```
38
46
  投稿一覧のcollectionを返してくれます。

1

修正

2020/11/11 12:56

投稿

renren643
renren643

スコア279

title CHANGED
File without changes
body CHANGED
@@ -13,13 +13,13 @@
13
13
  ```
14
14
  public function getPosts($with = [], $isPaginate = false)
15
15
  {
16
- $buildings = Building::with($with);
16
+ $posts = Post::with($with);
17
17
 
18
18
  if($isPaginate){
19
- $buildings->paginate(10)
19
+ $posts->paginate(10)
20
20
  }
21
21
 
22
- return $buildings->get();
22
+ return $posts->get();
23
23
  }
24
24
  ```
25
25
  このメソッドは