回答編集履歴
1
やりたいことに出来るだけ忠実な処理に修正
test
CHANGED
@@ -1,18 +1,28 @@
|
|
1
|
-
|
1
|
+
どうようなデータでどのような一覧を出したいのか、何がしたいのか良く分からない…
|
2
2
|
|
3
3
|
```php
|
4
4
|
|
5
|
-
// Controller
|
6
|
-
|
7
|
-
use App/review;
|
8
|
-
|
9
5
|
public function index()
|
10
6
|
|
11
|
-
{
|
7
|
+
{
|
8
|
+
|
9
|
+
$review = review::find(1);
|
10
|
+
|
11
|
+
$count = 0;
|
12
|
+
|
13
|
+
if (!empty($review->q1)) $count++;
|
14
|
+
|
15
|
+
if (!empty($review->q2)) $count++;
|
16
|
+
|
17
|
+
if (!empty($review->q3)) $count++;
|
18
|
+
|
19
|
+
if (!empty($review->q4)) $count++;
|
20
|
+
|
21
|
+
|
12
22
|
|
13
23
|
$reviews = review::all();
|
14
24
|
|
15
|
-
return view('index', ['reviews' => $reviews]);
|
25
|
+
return view('index', ['reviews' => $reviews, 'count' => $count]);
|
16
26
|
|
17
27
|
}
|
18
28
|
|
@@ -20,11 +30,21 @@
|
|
20
30
|
|
21
31
|
```php
|
22
32
|
|
23
|
-
// View
|
24
|
-
|
25
33
|
@foreach ($reviews as $review)
|
26
34
|
|
27
|
-
{{
|
35
|
+
@if($loop->iteration == 1){{$review->name}}... {{$review->q1}}@endif
|
36
|
+
|
37
|
+
@if($loop->iteration == 2){{$review->name}}... {{$review->q2}}@endif
|
38
|
+
|
39
|
+
@if($loop->iteration == 3){{$review->name}}... {{$review->q3}}@endif
|
40
|
+
|
41
|
+
@if($loop->iteration == 4){{$review->name}}... {{$review->q4}}@endif
|
42
|
+
|
43
|
+
@if($count == $loop->iteration)
|
44
|
+
|
45
|
+
@break
|
46
|
+
|
47
|
+
@endif
|
28
48
|
|
29
49
|
@endforeach
|
30
50
|
|