質問編集履歴
1
バリデーションコードの表示
test
CHANGED
File without changes
|
test
CHANGED
@@ -346,6 +346,138 @@
|
|
346
346
|
|
347
347
|
```
|
348
348
|
|
349
|
+
app/Http/Controllers/Auth/RegisterController.php(抜粋)
|
350
|
+
|
351
|
+
```
|
352
|
+
|
353
|
+
protected function validator(array $data)
|
354
|
+
|
355
|
+
{
|
356
|
+
|
357
|
+
return Validator::make($data, [
|
358
|
+
|
359
|
+
'name' => 'required|string|max:255',
|
360
|
+
|
361
|
+
'email' => 'required|string|email|max:255|unique:users',
|
362
|
+
|
363
|
+
'password' => 'required|string|min:6|confirmed',
|
364
|
+
|
365
|
+
]);
|
366
|
+
|
367
|
+
```
|
368
|
+
|
369
|
+
app/Http/Controllers/TasksController.php(抜粋)
|
370
|
+
|
371
|
+
```
|
372
|
+
|
373
|
+
public function store(Request $request)
|
374
|
+
|
375
|
+
{
|
376
|
+
|
377
|
+
$this->validate($request, [
|
378
|
+
|
379
|
+
'title' =>'required|max:20',
|
380
|
+
|
381
|
+
'start_date' => 'required',
|
382
|
+
|
383
|
+
'start_time' => 'required',
|
384
|
+
|
385
|
+
'end_date' =>'required',
|
386
|
+
|
387
|
+
'end_time' =>'required',
|
388
|
+
|
389
|
+
'place' => 'required|max:20',
|
390
|
+
|
391
|
+
'content' => 'required|max:191',
|
392
|
+
|
393
|
+
]);
|
394
|
+
|
395
|
+
|
396
|
+
|
397
|
+
$request->user()->tasks()->create([
|
398
|
+
|
399
|
+
'title' => $request->title,
|
400
|
+
|
401
|
+
'start_date' =>$request->start_date,
|
402
|
+
|
403
|
+
'start_time' =>$request->start_time,
|
404
|
+
|
405
|
+
'end_date' =>$request->end_date,
|
406
|
+
|
407
|
+
'end_time' =>$request->end_time,
|
408
|
+
|
409
|
+
'place' =>$request->place,
|
410
|
+
|
411
|
+
'content'=>$request->content,
|
412
|
+
|
413
|
+
]);
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
return redirect('/');
|
418
|
+
|
419
|
+
~略~
|
420
|
+
|
421
|
+
public function update(Request $request, $id)
|
422
|
+
|
423
|
+
{
|
424
|
+
|
425
|
+
$this->validate($request, [
|
426
|
+
|
427
|
+
'title' =>'required|max:20',
|
428
|
+
|
429
|
+
'start_date' => 'required',
|
430
|
+
|
431
|
+
'start_time' => 'required',
|
432
|
+
|
433
|
+
'end_date' =>'required',
|
434
|
+
|
435
|
+
'end_time' =>'required',
|
436
|
+
|
437
|
+
'place' => 'required|max:20',
|
438
|
+
|
439
|
+
'content' => 'required|max:191',
|
440
|
+
|
441
|
+
|
442
|
+
|
443
|
+
]);
|
444
|
+
|
445
|
+
$task = Task::find($id);
|
446
|
+
|
447
|
+
if (\Auth::id() !== $task->user_id) {
|
448
|
+
|
449
|
+
return redirect('/');
|
450
|
+
|
451
|
+
}
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
$task->title = $request->title;
|
456
|
+
|
457
|
+
$task->start_date = $request->start_date;
|
458
|
+
|
459
|
+
$task->start_time = $request->start_time;
|
460
|
+
|
461
|
+
$task->end_date = $request->end_date;
|
462
|
+
|
463
|
+
$task->end_time = $request->end_time;
|
464
|
+
|
465
|
+
$task->place = $request->place;
|
466
|
+
|
467
|
+
$task->content = $request->content;
|
468
|
+
|
469
|
+
$task->save();
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
return redirect('/');
|
474
|
+
|
475
|
+
}
|
476
|
+
|
477
|
+
```
|
478
|
+
|
479
|
+
|
480
|
+
|
349
481
|
|
350
482
|
|
351
483
|
### 試したこと
|