From 94918fc33719aab66e22031cc208ab97ba7df7da Mon Sep 17 00:00:00 2001 From: shibafu Date: Sun, 5 Nov 2017 19:14:36 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E7=94=BB=E9=9D=A2=E3=81=AE=E3=83=AC=E3=82=A4=E3=82=A2?= =?UTF-8?q?=E3=82=A6=E3=83=88=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 別にレイアウト変わってないので焼き直しが正しい --- .../Controllers/EjaculationController.php | 11 +- resources/views/ejaculation/checkin.blade.php | 141 +++++++++++------- 2 files changed, 91 insertions(+), 61 deletions(-) diff --git a/app/Http/Controllers/EjaculationController.php b/app/Http/Controllers/EjaculationController.php index b648abd..78ba14d 100644 --- a/app/Http/Controllers/EjaculationController.php +++ b/app/Http/Controllers/EjaculationController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\User; +use Carbon\Carbon; use Validator; use App\Ejaculation; use Illuminate\Http\Request; @@ -23,15 +24,17 @@ class EjaculationController extends Controller 'note' => 'nullable|string|max:500', ])->after(function ($validator) use ($request) { // 日時の重複チェック - $dt = $request->input('date') . ' ' . $request->input('time'); - if (Ejaculation::where(['user_id' => Auth::id(), 'ejaculated_date' => $dt])->count()) { - $validator->errors()->add('datetime', '既にこの日時にチェックインしているため、登録できません。'); + if (!$validator->errors()->hasAny(['date', 'time'])) { + $dt = $request->input('date') . ' ' . $request->input('time'); + if (Ejaculation::where(['user_id' => Auth::id(), 'ejaculated_date' => $dt])->count()) { + $validator->errors()->add('datetime', '既にこの日時にチェックインしているため、登録できません。'); + } } })->validate(); Ejaculation::create([ 'user_id' => Auth::id(), - 'ejaculated_date' => $request->input('date') . ' ' . $request->input('time'), + 'ejaculated_date' => Carbon::createFromFormat('Y/m/d H:i', $request->input('date') . ' ' . $request->input('time')), 'note' => $request->input('note') ?? '', 'is_private' => $request->has('is_private') ?? false ]); diff --git a/resources/views/ejaculation/checkin.blade.php b/resources/views/ejaculation/checkin.blade.php index 24b2067..4130d60 100644 --- a/resources/views/ejaculation/checkin.blade.php +++ b/resources/views/ejaculation/checkin.blade.php @@ -1,83 +1,110 @@ -@extends('layouts.base-old') +@extends('layouts.base') @section('content')
-

今致してる?

-
-
- {{ csrf_field() }} +

今致してる?

+
+
+
+ + {{ csrf_field() }} -
-
-
- today - - +
+
+ + @if ($errors->has('date')) - {{ $errors->first('date') }} +
{{ $errors->first('date') }}
@endif
-
- schedule - - +
+ + @if ($errors->has('time')) - {{ $errors->first('time') }} +
{{ $errors->first('time') }}
@endif
@if ($errors->has('datetime')) -
- {{ $errors->first('datetime') }} -
+
+ {{ $errors->first('datetime') }} +
@endif -
- label - - +
+ {{-- +
+
+ + + + スペース区切りで複数入力できます。 +
- {{--
--}} - {{--TODO: Material Chipsデータのシリアライズとかをjsで書いておく必要あるかも? --}} - {{--label--}} - {{--
--}} - {{----}} - {{--
--}} -
- comment - - - +
+
+
+ + + + オカズのURLを貼り付けて登録することができます。 + +
+
+
+
このオカズで合っていますか?
+
+
+ +
+

タイトル

+ 概要 +
+
+ 決定 + キャンセル +
+
+
+
+ --}} +
+
+ + + + 最大 500 文字 + @if ($errors->has('note')) - {{ $errors->first('note') }} +
{{ $errors->first('note') }}
@endif
-
-
-
オプション
-

- - -

+
+

オプション

+
+
+ +
-
-
- -
+ +
+
-
- + +
@endsection -@section('script') - -@endsection \ No newline at end of file +@push('script') +@endpush \ No newline at end of file