From 336d368369cd6f428df9807a71552fd73fd66400 Mon Sep 17 00:00:00 2001 From: shibafu Date: Mon, 8 Jan 2018 15:23:58 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=BF=E3=82=B0=E6=9C=AA=E5=85=A5=E5=8A=9B?= =?UTF-8?q?=E6=99=82=E3=81=AB=E7=A9=BA=E7=99=BD=E3=81=AE=E3=82=BF=E3=82=B0?= =?UTF-8?q?=E3=81=8C=E7=94=9F=E6=88=90=E3=81=95=E3=82=8C=E3=82=8B=E3=83=90?= =?UTF-8?q?=E3=82=B0=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/EjaculationController.php | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/EjaculationController.php b/app/Http/Controllers/EjaculationController.php index 834af24..13a6d37 100644 --- a/app/Http/Controllers/EjaculationController.php +++ b/app/Http/Controllers/EjaculationController.php @@ -48,11 +48,13 @@ class EjaculationController extends Controller 'is_private' => $request->has('is_private') ?? false ]); - $tags = explode(' ', $inputs['tags']); $tagIds = []; - foreach ($tags as $tag) { - $tag = Tag::firstOrCreate(['name' => $tag]); - $tagIds[] = $tag->id; + if (!empty($inputs['tags'])) { + $tags = explode(' ', $inputs['tags']); + foreach ($tags as $tag) { + $tag = Tag::firstOrCreate(['name' => $tag]); + $tagIds[] = $tag->id; + } } $ejaculation->tags()->sync($tagIds); @@ -119,11 +121,13 @@ 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; + if (!empty($inputs['tags'])) { + $tags = explode(' ', $inputs['tags']); + foreach ($tags as $tag) { + $tag = Tag::firstOrCreate(['name' => $tag]); + $tagIds[] = $tag->id; + } } $ejaculation->tags()->sync($tagIds);