質問編集履歴
1
コードを詳細に書き直しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -20,6 +20,18 @@
|
|
20
20
|
|
21
21
|
```php
|
22
22
|
|
23
|
+
//追加ページ
|
24
|
+
|
25
|
+
public function create() {
|
26
|
+
|
27
|
+
$month = Client::$month;
|
28
|
+
|
29
|
+
return view('client.create', compact('month'));
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
//追加の確認
|
34
|
+
|
23
35
|
public function confirm(ClientRequest $request) {
|
24
36
|
|
25
37
|
$data = $request->all();
|
@@ -34,6 +46,42 @@
|
|
34
46
|
|
35
47
|
}
|
36
48
|
|
49
|
+
|
50
|
+
|
51
|
+
//追加の処理
|
52
|
+
|
53
|
+
public function store(ClientRequest $request) {
|
54
|
+
|
55
|
+
$action = $request->get('action');// name=action の value名を取得
|
56
|
+
|
57
|
+
$input = $request->except('action');// 入力内容を取得
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
if ($action === "確定") {
|
62
|
+
|
63
|
+
$clients = new Client();
|
64
|
+
|
65
|
+
$clients->name = $request->ClientName;
|
66
|
+
|
67
|
+
$clients->month = $request->ClientMonth;
|
68
|
+
|
69
|
+
$clients->body = $request->ClientBody;
|
70
|
+
|
71
|
+
$clients->save();
|
72
|
+
|
73
|
+
return redirect('/client/list');
|
74
|
+
|
75
|
+
} else {
|
76
|
+
|
77
|
+
return redirect('/client/create')->withInput($input);
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
}
|
84
|
+
|
37
85
|
```
|
38
86
|
|
39
87
|
|
@@ -41,6 +89,28 @@
|
|
41
89
|
■viewファイル(入力画面)
|
42
90
|
|
43
91
|
```php
|
92
|
+
|
93
|
+
<form class="" action="{{ url('/client/confirm') }}" method="post">
|
94
|
+
|
95
|
+
{{ csrf_field() }}
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<p>
|
100
|
+
|
101
|
+
<input type="text" name="ClientName" placeholder="名前" value="{{ old('ClientName') }}">
|
102
|
+
|
103
|
+
@if($errors->has('ClientName'))
|
104
|
+
|
105
|
+
<span class="error">{{ $errors->first('ClientName') }}</span>
|
106
|
+
|
107
|
+
@endif
|
108
|
+
|
109
|
+
</p>
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
<p>
|
44
114
|
|
45
115
|
@foreach($month as $key => $value)
|
46
116
|
|
@@ -54,6 +124,28 @@
|
|
54
124
|
|
55
125
|
@endforeach
|
56
126
|
|
127
|
+
</p>
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<p>
|
132
|
+
|
133
|
+
<textarea name="ClientBody" rows="8" cols="80" placeholder="本文">{{ old('ClientBody') }}</textarea>
|
134
|
+
|
135
|
+
@if($errors->has('ClientBody'))
|
136
|
+
|
137
|
+
<span class="error">{{ $errors->first('ClientBody') }}</span>
|
138
|
+
|
139
|
+
@endif
|
140
|
+
|
141
|
+
</p>
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<input type="submit" value="登録">
|
146
|
+
|
147
|
+
</form>
|
148
|
+
|
57
149
|
```
|
58
150
|
|
59
151
|
|
@@ -62,8 +154,42 @@
|
|
62
154
|
|
63
155
|
```php
|
64
156
|
|
157
|
+
<form class="" action="{{ url('/client') }}" method="post">
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
<input type="hidden" name="ClientName" value="{{ $ClientName }}">
|
162
|
+
|
163
|
+
<input type="hidden" name="ClientMonth" value="{{ $month }}">
|
164
|
+
|
165
|
+
<input type="hidden" name="ClientBody" value="{{ $ClientBody }}">
|
166
|
+
|
167
|
+
{{ csrf_field() }}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
この内容で登録します。
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
<ul>
|
176
|
+
|
177
|
+
<li>{{ $ClientName }}</li>
|
178
|
+
|
179
|
+
<li>{{ $month }}</li>
|
180
|
+
|
181
|
+
<li>{!! nl2br(e($ClientBody)) !!}</li>
|
182
|
+
|
183
|
+
</ul>
|
184
|
+
|
185
|
+
|
186
|
+
|
65
187
|
<input type="submit" name="action" value="戻る">
|
66
188
|
|
67
189
|
<input type="submit" name="action" value="確定">
|
68
190
|
|
191
|
+
|
192
|
+
|
193
|
+
</form>
|
194
|
+
|
69
195
|
```
|