タグ未入力時に空白のタグが生成されるバグの修正
This commit is contained in:
parent
917675f9bd
commit
336d368369
@ -48,12 +48,14 @@ class EjaculationController extends Controller
|
|||||||
'is_private' => $request->has('is_private') ?? false
|
'is_private' => $request->has('is_private') ?? false
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$tags = explode(' ', $inputs['tags']);
|
|
||||||
$tagIds = [];
|
$tagIds = [];
|
||||||
|
if (!empty($inputs['tags'])) {
|
||||||
|
$tags = explode(' ', $inputs['tags']);
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
$tag = Tag::firstOrCreate(['name' => $tag]);
|
$tag = Tag::firstOrCreate(['name' => $tag]);
|
||||||
$tagIds[] = $tag->id;
|
$tagIds[] = $tag->id;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$ejaculation->tags()->sync($tagIds);
|
$ejaculation->tags()->sync($tagIds);
|
||||||
|
|
||||||
return redirect()->route('checkin.show', ['id' => $ejaculation->id])->with('status', 'チェックインしました!');
|
return redirect()->route('checkin.show', ['id' => $ejaculation->id])->with('status', 'チェックインしました!');
|
||||||
@ -119,12 +121,14 @@ 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 = [];
|
||||||
|
if (!empty($inputs['tags'])) {
|
||||||
|
$tags = explode(' ', $inputs['tags']);
|
||||||
foreach ($tags as $tag) {
|
foreach ($tags as $tag) {
|
||||||
$tag = Tag::firstOrCreate(['name' => $tag]);
|
$tag = Tag::firstOrCreate(['name' => $tag]);
|
||||||
$tagIds[] = $tag->id;
|
$tagIds[] = $tag->id;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$ejaculation->tags()->sync($tagIds);
|
$ejaculation->tags()->sync($tagIds);
|
||||||
|
|
||||||
return redirect()->route('checkin.show', ['id' => $ejaculation->id])->with('status', 'チェックインを修正しました!');
|
return redirect()->route('checkin.show', ['id' => $ejaculation->id])->with('status', 'チェックインを修正しました!');
|
||||||
|
Loading…
Reference in New Issue
Block a user