質問編集履歴
1
$collectionに何が入ってるのかの詳細
test
CHANGED
File without changes
|
test
CHANGED
@@ -29,3 +29,249 @@
|
|
29
29
|
など調べましたが、法律を調べましたがどういったものが法律に触るのかがわかりませんでした。
|
30
30
|
|
31
31
|
```
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
### 追記いたします
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
TypesController
|
40
|
+
|
41
|
+
```php
|
42
|
+
|
43
|
+
<?php
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
namespace App\Http\Controllers;
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
use App\Word;
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
class TypesController extends Controller
|
56
|
+
|
57
|
+
{
|
58
|
+
|
59
|
+
public function index() {
|
60
|
+
|
61
|
+
$collection = Word::get();
|
62
|
+
|
63
|
+
//dd($collection->toArray());
|
64
|
+
|
65
|
+
return view('types.index',compact('collection'));
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
```
|
72
|
+
|
73
|
+
wordsテーブル
|
74
|
+
|
75
|
+
![DB](0cbedacfd2881e6311a3c42f77398be4.png)
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
dd($collection);の結果
|
80
|
+
|
81
|
+
```
|
82
|
+
|
83
|
+
array:3 [▼
|
84
|
+
|
85
|
+
0 => array:6 [▼
|
86
|
+
|
87
|
+
"id" => 2
|
88
|
+
|
89
|
+
"word1" => "前田利家"
|
90
|
+
|
91
|
+
"word2" => "まえだとしいえ"
|
92
|
+
|
93
|
+
"level" => 11
|
94
|
+
|
95
|
+
"created_at" => "2020-06-25 12:15:21"
|
96
|
+
|
97
|
+
"updated_at" => "2020-06-25 12:15:21"
|
98
|
+
|
99
|
+
]
|
100
|
+
|
101
|
+
1 => array:6 [▼
|
102
|
+
|
103
|
+
"id" => 3
|
104
|
+
|
105
|
+
"word1" => "絵画"
|
106
|
+
|
107
|
+
"word2" => "かいが"
|
108
|
+
|
109
|
+
"level" => 5
|
110
|
+
|
111
|
+
"created_at" => "2020-06-25 12:16:10"
|
112
|
+
|
113
|
+
"updated_at" => "2020-06-25 12:16:10"
|
114
|
+
|
115
|
+
]
|
116
|
+
|
117
|
+
2 => array:6 [▼
|
118
|
+
|
119
|
+
"id" => 4
|
120
|
+
|
121
|
+
"word1" => "古代エジプト"
|
122
|
+
|
123
|
+
"word2" => "こだいえじぷと"
|
124
|
+
|
125
|
+
"level" => 12
|
126
|
+
|
127
|
+
"created_at" => "2020-06-25 22:35:54"
|
128
|
+
|
129
|
+
"updated_at" => "2020-06-25 22:35:54"
|
130
|
+
|
131
|
+
]
|
132
|
+
|
133
|
+
]
|
134
|
+
|
135
|
+
```
|
136
|
+
|
137
|
+
以上が$collectionの中身です
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
types/index.blade.php
|
142
|
+
|
143
|
+
```php
|
144
|
+
|
145
|
+
<!DOCTYPE html>
|
146
|
+
|
147
|
+
<html lang="ja">
|
148
|
+
|
149
|
+
<head>
|
150
|
+
|
151
|
+
<meta charset="utf-8">
|
152
|
+
|
153
|
+
<title>Typing Game</title>
|
154
|
+
|
155
|
+
<link rel="stylesheet" href="css/typing.css">
|
156
|
+
|
157
|
+
</head>
|
158
|
+
|
159
|
+
<body>
|
160
|
+
|
161
|
+
<header class="container">
|
162
|
+
|
163
|
+
<div id="target">Enterを押して開始します!!</div>
|
164
|
+
|
165
|
+
<div id="hiragana">fight!!!</div>
|
166
|
+
|
167
|
+
<div id="reading">fight!!!</div>
|
168
|
+
|
169
|
+
<div class="info clearfix">
|
170
|
+
|
171
|
+
<div class="letter">正答数: <span id="score">0</span></div>
|
172
|
+
|
173
|
+
<div class="miss">ミス数: <span id="miss">0</span></div>
|
174
|
+
|
175
|
+
</div>
|
176
|
+
|
177
|
+
</header>
|
178
|
+
|
179
|
+
<main class="container">
|
180
|
+
|
181
|
+
<div class="enemy-area clearfix"></div>
|
182
|
+
|
183
|
+
</main>
|
184
|
+
|
185
|
+
<footer>
|
186
|
+
|
187
|
+
<div class="enemys"></div>
|
188
|
+
|
189
|
+
</footer>
|
190
|
+
|
191
|
+
<video id="video">
|
192
|
+
|
193
|
+
<source src="music/swing2.mp3">
|
194
|
+
|
195
|
+
</video>
|
196
|
+
|
197
|
+
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
198
|
+
|
199
|
+
<script>
|
200
|
+
|
201
|
+
let words = {!! json_encode($collection) !!};
|
202
|
+
|
203
|
+
</script>
|
204
|
+
|
205
|
+
<script src="js/typing.js"></script>
|
206
|
+
|
207
|
+
</body>
|
208
|
+
|
209
|
+
</html>
|
210
|
+
|
211
|
+
```
|
212
|
+
|
213
|
+
words/index.blade.php(タイピングワード登録用ページ(私だけが登録できる))
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
```php
|
218
|
+
|
219
|
+
@extends('layouts.default')
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
@section('title', 'Words')
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
@section('content')
|
228
|
+
|
229
|
+
<div id="result"></div>
|
230
|
+
|
231
|
+
<h1>
|
232
|
+
|
233
|
+
<a href="{{ action('TypesController@index') }}">Game Start</a>
|
234
|
+
|
235
|
+
<a href="{{ action('WordsController@create') }}" class="header-menu">新規登録</a>
|
236
|
+
|
237
|
+
</h1>
|
238
|
+
|
239
|
+
<ul class="clearfix">
|
240
|
+
|
241
|
+
@forelse ($words as $word)
|
242
|
+
|
243
|
+
<li class="menu">
|
244
|
+
|
245
|
+
<p><a href="{{ action('WordsController@show', $word) }}">{{ $word->word1 }}</a></p>
|
246
|
+
|
247
|
+
<p><a href="{{ action('WordsController@show', $word) }}">{{ $word->word2 }}</a></p>
|
248
|
+
|
249
|
+
<a href="{{ action('WordsController@edit', $word) }}">[編集]</a>
|
250
|
+
|
251
|
+
<a href="#" class="del" data-id="{{ $word->id }}">[削除]</a>
|
252
|
+
|
253
|
+
<form method="post" action="{{ action('WordsController@destroy', $word) }}" id="form_{{ $word->id }}">
|
254
|
+
|
255
|
+
{{ csrf_field() }}
|
256
|
+
|
257
|
+
{{ method_field('delete') }}
|
258
|
+
|
259
|
+
</form>
|
260
|
+
|
261
|
+
</li>
|
262
|
+
|
263
|
+
@empty
|
264
|
+
|
265
|
+
<li>No words yet</li>
|
266
|
+
|
267
|
+
@endforelse
|
268
|
+
|
269
|
+
</ul>
|
270
|
+
|
271
|
+
<div>{{ $words->links() }}</div>
|
272
|
+
|
273
|
+
@endsection
|
274
|
+
|
275
|
+
```
|
276
|
+
|
277
|
+
おおまかですが、このような感じです。
|