チェックイン編集画面もタグ登録に対応
This commit is contained in:
@@ -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', 'チェックインを修正しました!');
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user