質問編集履歴
2
すみません、修正しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -78,7 +78,7 @@
|
|
78
78
|
|
79
79
|
コントローラー
|
80
80
|
|
81
|
-
|
81
|
+
// 編集画面 遷移
|
82
82
|
|
83
83
|
public function sendData($id){
|
84
84
|
|
@@ -144,13 +144,13 @@
|
|
144
144
|
|
145
145
|
}
|
146
146
|
|
147
|
-
|
147
|
+
```
|
148
148
|
|
149
149
|
```laravel
|
150
150
|
|
151
151
|
view 入力フォーム
|
152
152
|
|
153
|
-
|
153
|
+
@extends('layout/layout')
|
154
154
|
|
155
155
|
|
156
156
|
|
@@ -352,13 +352,13 @@
|
|
352
352
|
|
353
353
|
@stop
|
354
354
|
|
355
|
-
|
355
|
+
```
|
356
356
|
|
357
357
|
```laravel
|
358
358
|
|
359
359
|
|
360
360
|
|
361
|
-
|
361
|
+
@extends('layout/layout')
|
362
362
|
|
363
363
|
|
364
364
|
|
@@ -512,7 +512,7 @@
|
|
512
512
|
|
513
513
|
@stop
|
514
514
|
|
515
|
-
|
515
|
+
```
|
516
516
|
|
517
517
|
![dd($data)の結果](144fbbe4729e8a0e111646395c511d47.png)
|
518
518
|
|
1
controller,view,dd()結果を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -67,3 +67,455 @@
|
|
67
67
|
|
68
68
|
|
69
69
|
よろしくお願いいたします。
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
### 追記
|
76
|
+
|
77
|
+
```laravel
|
78
|
+
|
79
|
+
コントローラー
|
80
|
+
|
81
|
+
``` // 編集画面 遷移
|
82
|
+
|
83
|
+
public function sendData($id){
|
84
|
+
|
85
|
+
$info = Article::find($id);
|
86
|
+
|
87
|
+
return view('article/edit',['info'=>$info]);
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
// 編集 確認画面
|
94
|
+
|
95
|
+
public function confirmEdit(ArticleRequest $request)
|
96
|
+
|
97
|
+
{
|
98
|
+
|
99
|
+
$info = $request->all();
|
100
|
+
|
101
|
+
return view('article/edit_confirm',compact('info'));
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
// 更新画面
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
public function edit(ArticleRequest $request)
|
112
|
+
|
113
|
+
{
|
114
|
+
|
115
|
+
$id =$request->id;
|
116
|
+
|
117
|
+
$data = Article::find($id);
|
118
|
+
|
119
|
+
// 取得したデータに上書きする
|
120
|
+
|
121
|
+
$data->name = $request->name;
|
122
|
+
|
123
|
+
$data->email = $request->email;
|
124
|
+
|
125
|
+
$data->age = $request->age;
|
126
|
+
|
127
|
+
$data->area = $request->area;
|
128
|
+
|
129
|
+
$data->gender = $request->gender;
|
130
|
+
|
131
|
+
$data->media1 = $request->media1;
|
132
|
+
|
133
|
+
$data->media2 = $request->media2;
|
134
|
+
|
135
|
+
$data->note = $request->note;
|
136
|
+
|
137
|
+
$data->image = $request->image;
|
138
|
+
|
139
|
+
$data->save();
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
return view('/article/edit_complete',compact('data'));
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
```laravel
|
150
|
+
|
151
|
+
view 入力フォーム
|
152
|
+
|
153
|
+
```@extends('layout/layout')
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
@section('content')
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
@if($errors->any())
|
162
|
+
|
163
|
+
<div class="errors">
|
164
|
+
|
165
|
+
<ul>
|
166
|
+
|
167
|
+
@foreach($errors->all() as $error)
|
168
|
+
|
169
|
+
<li>{{ $error }}</li>
|
170
|
+
|
171
|
+
@endforeach
|
172
|
+
|
173
|
+
</ul>
|
174
|
+
|
175
|
+
</div>
|
176
|
+
|
177
|
+
@endif
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
<div class="row">
|
184
|
+
|
185
|
+
<form method="post" action="{{ url('/article/insert_confirm')}}">
|
186
|
+
|
187
|
+
{{ csrf_field() }}
|
188
|
+
|
189
|
+
<br>
|
190
|
+
|
191
|
+
<br>
|
192
|
+
|
193
|
+
<h1>新規登録</h1>
|
194
|
+
|
195
|
+
<br>
|
196
|
+
|
197
|
+
<div class="form-group @if(!empty($errors->first('name'))) has-error @endif">
|
198
|
+
|
199
|
+
<label>名前</label>
|
200
|
+
|
201
|
+
<input type="text" name="name" class="form-control">
|
202
|
+
|
203
|
+
<span class="help-block">{{$errors->first('name')}}</span>
|
204
|
+
|
205
|
+
</div>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
<div class="form-group @if(!empty($errors->first('email'))) has-error @endif">
|
210
|
+
|
211
|
+
<label>E-Mail</label>
|
212
|
+
|
213
|
+
<input type="mail" name="email" class="form-control">
|
214
|
+
|
215
|
+
<span class="help-block">{{$errors->first('email')}}</span>
|
216
|
+
|
217
|
+
</div>
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<div class="form-group @if(!empty($errors->first('age'))) has-error @endif">
|
222
|
+
|
223
|
+
<label>年齢</label>
|
224
|
+
|
225
|
+
<input type="number" name="age" class="form-control">
|
226
|
+
|
227
|
+
<span class="help-block">{{$errors->first('age')}}</span>
|
228
|
+
|
229
|
+
</div>
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
<div class="form-group @if(!empty($errors->first('area'))) has-error @endif">
|
234
|
+
|
235
|
+
<label>エリア</label>
|
236
|
+
|
237
|
+
<select name="area" class="form-control">
|
238
|
+
|
239
|
+
<option value="east" selected>東日本</option>
|
240
|
+
|
241
|
+
<option value="west">西日本</option>
|
242
|
+
|
243
|
+
</select>
|
244
|
+
|
245
|
+
<span class="help-block">{{$errors->first('area')}}</span>
|
246
|
+
|
247
|
+
</div>
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
<p><b>性別</b></p>
|
252
|
+
|
253
|
+
<div class="radio-inline @if(!empty($errors->first('gender'))) has-error @endif">
|
254
|
+
|
255
|
+
<label>
|
256
|
+
|
257
|
+
<input type="radio" name="gender" value="1" checked>男性
|
258
|
+
|
259
|
+
</label>
|
260
|
+
|
261
|
+
<span class="help-block">{{$errors->first('gender')}}</span>
|
262
|
+
|
263
|
+
</div>
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
<div class="radio-inline">
|
268
|
+
|
269
|
+
<label>
|
270
|
+
|
271
|
+
<input type="radio" name="gender" value="2" @if(Request::old('gender')=="2") ckecked @endif>女性
|
272
|
+
|
273
|
+
</label>
|
274
|
+
|
275
|
+
<span class="help-block">{{$errors->first('gender')}}</span>
|
276
|
+
|
277
|
+
</div>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
<p><b>告知メディア</b></p>
|
282
|
+
|
283
|
+
<div class="form-check @if(!empty($errors->first('media1'))) has->error @endif">
|
284
|
+
|
285
|
+
<label>
|
286
|
+
|
287
|
+
<input type="hidden" name="media1" value="">
|
288
|
+
|
289
|
+
<input type="checkbox" name="media1" value="web" @if(Request::old('media1')=="web") checked @endif>web
|
290
|
+
|
291
|
+
</label>
|
292
|
+
|
293
|
+
<span class="help-block">{{$errors->first('media1')}}</span>
|
294
|
+
|
295
|
+
</div>
|
296
|
+
|
297
|
+
<div class="form-check @if(!empty($errors->first('media2'))) has->error @endif">
|
298
|
+
|
299
|
+
<label>
|
300
|
+
|
301
|
+
<input type="hidden" name="media2" value="">
|
302
|
+
|
303
|
+
<input type="checkbox" name="media2" value="tv" @if(Request::old('media2')=="tv") checked @endif>tv
|
304
|
+
|
305
|
+
</label>
|
306
|
+
|
307
|
+
<span class="help-block">{{$errors->first('media2')}}</span>
|
308
|
+
|
309
|
+
</div>
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
<div class="textarea @if(!empty($errors->first('note'))) has->error @endif">
|
314
|
+
|
315
|
+
<!-- <label for="textarea1">ご意見</label> -->
|
316
|
+
|
317
|
+
<textarea id="textarea1" class="form-control" name="note" placeholder="ご自由に入力ください。">{{Request::old('note')}}</textarea>
|
318
|
+
|
319
|
+
<span class="help-block">{{$errors->first('note')}}</span>
|
320
|
+
|
321
|
+
</div>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
<div class="image @if(!empty($errors->first('image'))) has->error @endif">
|
326
|
+
|
327
|
+
<input type="file" name="image">
|
328
|
+
|
329
|
+
<span class="help-block">{{$errors->first('image')}}</span>
|
330
|
+
|
331
|
+
</div>
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
<br><br>
|
336
|
+
|
337
|
+
<input type="submit" value="確認画面へ" class="btn btn-success">
|
338
|
+
|
339
|
+
</form>
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
<br>
|
344
|
+
|
345
|
+
<form method="post" action="{{ url('/article/list')}}">
|
346
|
+
|
347
|
+
{{ csrf_field() }}
|
348
|
+
|
349
|
+
<input type="submit" value="リスト一覧に戻る" class="btn btn-primary">
|
350
|
+
|
351
|
+
</form>
|
352
|
+
|
353
|
+
@stop
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
```laravel
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
```@extends('layout/layout')
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
@section('content')
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
@if (session('media'))
|
370
|
+
|
371
|
+
<div class="row">
|
372
|
+
|
373
|
+
<div class="col-md-8 col-md-offset-2">
|
374
|
+
|
375
|
+
<div class="alert alert-warning">
|
376
|
+
|
377
|
+
{{ session('media') }}
|
378
|
+
|
379
|
+
</div>
|
380
|
+
|
381
|
+
</div>
|
382
|
+
|
383
|
+
</div>
|
384
|
+
|
385
|
+
@endif
|
386
|
+
|
387
|
+
@yield('content')
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
<h1>編集内容確認</h1>
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
<table class="table table-striped">
|
396
|
+
|
397
|
+
<tr>
|
398
|
+
|
399
|
+
<td>名前</td>
|
400
|
+
|
401
|
+
<td>{{$info['name']}}</td>
|
402
|
+
|
403
|
+
</tr>
|
404
|
+
|
405
|
+
<tr>
|
406
|
+
|
407
|
+
<td>E-Mail</td>
|
408
|
+
|
409
|
+
<td>{{$info['email']}}</td>
|
410
|
+
|
411
|
+
</tr>
|
412
|
+
|
413
|
+
<tr>
|
414
|
+
|
415
|
+
<td>年齢</td>
|
416
|
+
|
417
|
+
<td>{{$info['age']}}</td>
|
418
|
+
|
419
|
+
</tr>
|
420
|
+
|
421
|
+
<tr>
|
422
|
+
|
423
|
+
<td>エリア</td>
|
424
|
+
|
425
|
+
<td>{{$info['area']}}</td>
|
426
|
+
|
427
|
+
</tr>
|
428
|
+
|
429
|
+
<tr>
|
430
|
+
|
431
|
+
<td>性別</td>
|
432
|
+
|
433
|
+
<td>{{$info['gender']}}</td>
|
434
|
+
|
435
|
+
</tr>
|
436
|
+
|
437
|
+
<tr>
|
438
|
+
|
439
|
+
<td>メディア1</td>
|
440
|
+
|
441
|
+
<td>{{$info['media1']}}</td>
|
442
|
+
|
443
|
+
</tr>
|
444
|
+
|
445
|
+
<tr>
|
446
|
+
|
447
|
+
<td>メディア2</td>
|
448
|
+
|
449
|
+
<td>{{$info['media2']}}</td>
|
450
|
+
|
451
|
+
</tr>
|
452
|
+
|
453
|
+
<tr>
|
454
|
+
|
455
|
+
<td>ご意見</td>
|
456
|
+
|
457
|
+
<td>{{$info['note']}}</td>
|
458
|
+
|
459
|
+
</tr>
|
460
|
+
|
461
|
+
<tr>
|
462
|
+
|
463
|
+
<td>画像</td>
|
464
|
+
|
465
|
+
<td>{{$info['image']}}</td>
|
466
|
+
|
467
|
+
</tr>
|
468
|
+
|
469
|
+
</td>
|
470
|
+
|
471
|
+
</tr>
|
472
|
+
|
473
|
+
</table>
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
<form action="/article/edit_complete" method="post">
|
478
|
+
|
479
|
+
{{ csrf_field() }}
|
480
|
+
|
481
|
+
<!--hidden -->
|
482
|
+
|
483
|
+
<input type="hidden" name="id" value="{{ $info['id'] }}">
|
484
|
+
|
485
|
+
<input type="hidden" name="name" value="{{ $info['name'] }}">
|
486
|
+
|
487
|
+
<input type="hidden" name="email" value="{{ $info['email'] }}">
|
488
|
+
|
489
|
+
<input type="hidden" name="age" value="{{ $info['age'] }}">
|
490
|
+
|
491
|
+
<input type="hidden" name="area" value="{{ $info['area'] }}">
|
492
|
+
|
493
|
+
<input type="hidden" name="gender" value="{{ $info['gender'] }}">
|
494
|
+
|
495
|
+
<input type="hidden" name="media1" value="{{ $info['media1'] }}">
|
496
|
+
|
497
|
+
<input type="hidden" name="media2" value="{{ $info['media2'] }}">
|
498
|
+
|
499
|
+
<input type="hidden" name="note" value="{{ $info['note'] }}">
|
500
|
+
|
501
|
+
<input type="hidden" name="image" enctype="multipart/form-data" value="{{ $info['image'] }}">
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
<input type="submit" value="編集実行" class="btn btn-primary">
|
506
|
+
|
507
|
+
<br><br>
|
508
|
+
|
509
|
+
<a href="/article/list" class="btn btn-success" style="maerin:20px">フォームに戻る</a>
|
510
|
+
|
511
|
+
</form>
|
512
|
+
|
513
|
+
@stop
|
514
|
+
|
515
|
+
|
516
|
+
|
517
|
+
![dd($data)の結果](144fbbe4729e8a0e111646395c511d47.png)
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
よろしくお願いいたします。
|