回答編集履歴
1
answer
CHANGED
@@ -1,16 +1,14 @@
|
|
1
|
-
効率の良し悪しは別として、私なら下記のように書くと思います。
|
1
|
+
効率の良し悪しは別として、私なら下記のように書くと思います。
|
2
|
-
|
3
|
-
|
2
|
+
|
4
|
-
$reports = Report::whereBetween('created_at', array($from, $to))
|
3
|
+
$reports = Report::whereBetween('created_at', array($from, $to))
|
5
|
-
->orderBy('created_at', 'DESC')
|
4
|
+
->orderBy('created_at', 'DESC')
|
6
|
-
->get();
|
5
|
+
->get();
|
7
|
-
|
6
|
+
|
8
|
-
foreach( $reports as $report ) {
|
7
|
+
foreach( $reports as $report ) {
|
9
|
-
|
8
|
+
$first = $report->created_at;
|
10
|
-
|
9
|
+
break;
|
11
|
-
}
|
10
|
+
}
|
12
|
-
$titles = $reports->lists('title');
|
11
|
+
$titles = $reports->lists('title');
|
13
|
-
|
12
|
+
|
14
|
-
echo $first;
|
13
|
+
echo $first;
|
15
|
-
dd($titles);
|
14
|
+
dd($titles);
|
16
|
-
```
|