回答編集履歴
1
回答追加
answer
CHANGED
@@ -8,4 +8,30 @@
|
|
8
8
|
|
9
9
|
最後の s 大事です
|
10
10
|
|
11
|
-
[laravel 5.4 pagenation](https://readouble.com/laravel/5.4/ja/pagination.html)
|
11
|
+
[laravel 5.4 pagenation](https://readouble.com/laravel/5.4/ja/pagination.html)
|
12
|
+
|
13
|
+
|
14
|
+
---
|
15
|
+
|
16
|
+
追記です。
|
17
|
+
|
18
|
+
paginate ですが、
|
19
|
+
```php
|
20
|
+
$query->paginate(3);
|
21
|
+
```
|
22
|
+
これは、クエリの実行もしているので、既にデータが取得されていると思います。
|
23
|
+
|
24
|
+
でその後に、
|
25
|
+
```php
|
26
|
+
$results = $query->get();
|
27
|
+
```
|
28
|
+
を実行すると、Collectionのget()が動くことになります。
|
29
|
+
|
30
|
+
Collectionのgetは引数に指定されたキーを抜き出すとか、そんな感じものですが、
|
31
|
+
上記のコードだと引数が空なので、戻り値がnullになっているかと思います。
|
32
|
+
|
33
|
+
なので、
|
34
|
+
```php
|
35
|
+
$results = $query->paginate(3);
|
36
|
+
```
|
37
|
+
これだけでいいのではないかと。。
|