タグ未入力時に空白のタグが生成されるバグの修正
This commit is contained in:
parent
917675f9bd
commit
336d368369
@ -48,11 +48,13 @@ class EjaculationController extends Controller
|
|||||||
'is_private' => $request->has('is_private') ?? false
|
'is_private' => $request->has('is_private') ?? false
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$tags = explode(' ', $inputs['tags']);
|
|
||||||
$tagIds = [];
|
$tagIds = [];
|
||||||
foreach ($tags as $tag) {
|
if (!empty($inputs['tags'])) {
|
||||||
$tag = Tag::firstOrCreate(['name' => $tag]);
|
$tags = explode(' ', $inputs['tags']);
|
||||||
$tagIds[] = $tag->id;
|
foreach ($tags as $tag) {
|
||||||
|
$tag = Tag::firstOrCreate(['name' => $tag]);
|
||||||
|
$tagIds[] = $tag->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$ejaculation->tags()->sync($tagIds);
|
$ejaculation->tags()->sync($tagIds);
|
||||||
|
|
||||||
@ -119,11 +121,13 @@ class EjaculationController extends Controller
|
|||||||
'is_private' => $request->has('is_private') ?? false
|
'is_private' => $request->has('is_private') ?? false
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
$tags = explode(' ', $inputs['tags']);
|
|
||||||
$tagIds = [];
|
$tagIds = [];
|
||||||
foreach ($tags as $tag) {
|
if (!empty($inputs['tags'])) {
|
||||||
$tag = Tag::firstOrCreate(['name' => $tag]);
|
$tags = explode(' ', $inputs['tags']);
|
||||||
$tagIds[] = $tag->id;
|
foreach ($tags as $tag) {
|
||||||
|
$tag = Tag::firstOrCreate(['name' => $tag]);
|
||||||
|
$tagIds[] = $tag->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$ejaculation->tags()->sync($tagIds);
|
$ejaculation->tags()->sync($tagIds);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user