From 24a3b0ebb58e91e8cb6bc0fbfd506f280a01e63b Mon Sep 17 00:00:00 2001 From: shibafu Date: Mon, 8 Jan 2018 08:56:17 +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=B7=A8=E9=9B=86=E7=94=BB=E9=9D=A2=E3=82=82=E3=82=BF?= =?UTF-8?q?=E3=82=B0=E7=99=BB=E9=8C=B2=E3=81=AB=E5=AF=BE=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/EjaculationController.php | 10 ++- resources/views/ejaculation/edit.blade.php | 67 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/EjaculationController.php b/app/Http/Controllers/EjaculationController.php index ca731c5..834af24 100644 --- a/app/Http/Controllers/EjaculationController.php +++ b/app/Http/Controllers/EjaculationController.php @@ -54,7 +54,6 @@ class EjaculationController extends Controller $tag = Tag::firstOrCreate(['name' => $tag]); $tagIds[] = $tag->id; } - $ejaculation->tags()->sync($tagIds); return redirect()->route('checkin.show', ['id' => $ejaculation->id])->with('status', 'チェックインしました!'); @@ -102,6 +101,7 @@ class EjaculationController extends Controller 'time' => 'required|date_format:H:i', 'note' => 'nullable|string|max:500', 'link' => 'nullable|url', + 'tags' => 'nullable|string', ])->after(function ($validator) use ($id, $request, $inputs) { // 日時の重複チェック if (!$validator->errors()->hasAny(['date', 'time'])) { @@ -119,6 +119,14 @@ class EjaculationController extends Controller 'is_private' => $request->has('is_private') ?? false ])->save(); + $tags = explode(' ', $inputs['tags']); + $tagIds = []; + foreach ($tags as $tag) { + $tag = Tag::firstOrCreate(['name' => $tag]); + $tagIds[] = $tag->id; + } + $ejaculation->tags()->sync($tagIds); + return redirect()->route('checkin.show', ['id' => $ejaculation->id])->with('status', 'チェックインを修正しました!'); } diff --git a/resources/views/ejaculation/edit.blade.php b/resources/views/ejaculation/edit.blade.php index f37837e..ed94a68 100644 --- a/resources/views/ejaculation/edit.blade.php +++ b/resources/views/ejaculation/edit.blade.php @@ -35,6 +35,23 @@ @endif +
+
+ + +
+
    + +
    + + Tab, Enter, 半角スペースのいずれかで入力確定します。 + + + @if ($errors->has('tags')) +
    {{ $errors->first('tags') }}
    + @endif +
    +
    {{--
    @@ -95,4 +112,54 @@ @endsection @push('script') + @endpush \ No newline at end of file