空文字列のタグは保存せず捨てる

This commit is contained in:
shibafu 2019-11-09 23:19:28 +09:00
parent af5de3ee14
commit 26be8a086e
1 changed files with 8 additions and 0 deletions

View File

@ -65,6 +65,10 @@ class EjaculationController extends Controller
if (!empty($inputs['tags'])) {
$tags = explode(' ', $inputs['tags']);
foreach ($tags as $tag) {
if ($tag === '') {
continue;
}
$tag = Tag::firstOrCreate(['name' => $tag]);
$tagIds[] = $tag->id;
}
@ -151,6 +155,10 @@ class EjaculationController extends Controller
if (!empty($inputs['tags'])) {
$tags = explode(' ', $inputs['tags']);
foreach ($tags as $tag) {
if ($tag === '') {
continue;
}
$tag = Tag::firstOrCreate(['name' => $tag]);
$tagIds[] = $tag->id;
}