質問編集履歴
1
$collectionに何が入ってるのかの詳細
title
CHANGED
File without changes
|
body
CHANGED
@@ -13,4 +13,127 @@
|
|
13
13
|
[https://web-kanji.com/posts/list-you-should-not-do](https://web-kanji.com/posts/list-you-should-not-do)
|
14
14
|
```
|
15
15
|
など調べましたが、法律を調べましたがどういったものが法律に触るのかがわかりませんでした。
|
16
|
-
```
|
16
|
+
```
|
17
|
+
|
18
|
+
### 追記いたします
|
19
|
+
|
20
|
+
TypesController
|
21
|
+
```php
|
22
|
+
<?php
|
23
|
+
|
24
|
+
namespace App\Http\Controllers;
|
25
|
+
|
26
|
+
use App\Word;
|
27
|
+
|
28
|
+
class TypesController extends Controller
|
29
|
+
{
|
30
|
+
public function index() {
|
31
|
+
$collection = Word::get();
|
32
|
+
//dd($collection->toArray());
|
33
|
+
return view('types.index',compact('collection'));
|
34
|
+
}
|
35
|
+
}
|
36
|
+
```
|
37
|
+
wordsテーブル
|
38
|
+

|
39
|
+
|
40
|
+
dd($collection);の結果
|
41
|
+
```
|
42
|
+
array:3 [▼
|
43
|
+
0 => array:6 [▼
|
44
|
+
"id" => 2
|
45
|
+
"word1" => "前田利家"
|
46
|
+
"word2" => "まえだとしいえ"
|
47
|
+
"level" => 11
|
48
|
+
"created_at" => "2020-06-25 12:15:21"
|
49
|
+
"updated_at" => "2020-06-25 12:15:21"
|
50
|
+
]
|
51
|
+
1 => array:6 [▼
|
52
|
+
"id" => 3
|
53
|
+
"word1" => "絵画"
|
54
|
+
"word2" => "かいが"
|
55
|
+
"level" => 5
|
56
|
+
"created_at" => "2020-06-25 12:16:10"
|
57
|
+
"updated_at" => "2020-06-25 12:16:10"
|
58
|
+
]
|
59
|
+
2 => array:6 [▼
|
60
|
+
"id" => 4
|
61
|
+
"word1" => "古代エジプト"
|
62
|
+
"word2" => "こだいえじぷと"
|
63
|
+
"level" => 12
|
64
|
+
"created_at" => "2020-06-25 22:35:54"
|
65
|
+
"updated_at" => "2020-06-25 22:35:54"
|
66
|
+
]
|
67
|
+
]
|
68
|
+
```
|
69
|
+
以上が$collectionの中身です
|
70
|
+
|
71
|
+
types/index.blade.php
|
72
|
+
```php
|
73
|
+
<!DOCTYPE html>
|
74
|
+
<html lang="ja">
|
75
|
+
<head>
|
76
|
+
<meta charset="utf-8">
|
77
|
+
<title>Typing Game</title>
|
78
|
+
<link rel="stylesheet" href="css/typing.css">
|
79
|
+
</head>
|
80
|
+
<body>
|
81
|
+
<header class="container">
|
82
|
+
<div id="target">Enterを押して開始します!!</div>
|
83
|
+
<div id="hiragana">fight!!!</div>
|
84
|
+
<div id="reading">fight!!!</div>
|
85
|
+
<div class="info clearfix">
|
86
|
+
<div class="letter">正答数: <span id="score">0</span></div>
|
87
|
+
<div class="miss">ミス数: <span id="miss">0</span></div>
|
88
|
+
</div>
|
89
|
+
</header>
|
90
|
+
<main class="container">
|
91
|
+
<div class="enemy-area clearfix"></div>
|
92
|
+
</main>
|
93
|
+
<footer>
|
94
|
+
<div class="enemys"></div>
|
95
|
+
</footer>
|
96
|
+
<video id="video">
|
97
|
+
<source src="music/swing2.mp3">
|
98
|
+
</video>
|
99
|
+
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
|
100
|
+
<script>
|
101
|
+
let words = {!! json_encode($collection) !!};
|
102
|
+
</script>
|
103
|
+
<script src="js/typing.js"></script>
|
104
|
+
</body>
|
105
|
+
</html>
|
106
|
+
```
|
107
|
+
words/index.blade.php(タイピングワード登録用ページ(私だけが登録できる))
|
108
|
+
|
109
|
+
```php
|
110
|
+
@extends('layouts.default')
|
111
|
+
|
112
|
+
@section('title', 'Words')
|
113
|
+
|
114
|
+
@section('content')
|
115
|
+
<div id="result"></div>
|
116
|
+
<h1>
|
117
|
+
<a href="{{ action('TypesController@index') }}">Game Start</a>
|
118
|
+
<a href="{{ action('WordsController@create') }}" class="header-menu">新規登録</a>
|
119
|
+
</h1>
|
120
|
+
<ul class="clearfix">
|
121
|
+
@forelse ($words as $word)
|
122
|
+
<li class="menu">
|
123
|
+
<p><a href="{{ action('WordsController@show', $word) }}">{{ $word->word1 }}</a></p>
|
124
|
+
<p><a href="{{ action('WordsController@show', $word) }}">{{ $word->word2 }}</a></p>
|
125
|
+
<a href="{{ action('WordsController@edit', $word) }}">[編集]</a>
|
126
|
+
<a href="#" class="del" data-id="{{ $word->id }}">[削除]</a>
|
127
|
+
<form method="post" action="{{ action('WordsController@destroy', $word) }}" id="form_{{ $word->id }}">
|
128
|
+
{{ csrf_field() }}
|
129
|
+
{{ method_field('delete') }}
|
130
|
+
</form>
|
131
|
+
</li>
|
132
|
+
@empty
|
133
|
+
<li>No words yet</li>
|
134
|
+
@endforelse
|
135
|
+
</ul>
|
136
|
+
<div>{{ $words->links() }}</div>
|
137
|
+
@endsection
|
138
|
+
```
|
139
|
+
おおまかですが、このような感じです。
|