diff --git a/app/Http/Controllers/App/Mission/EditorController.php b/app/Http/Controllers/App/Mission/EditorController.php index a6a578d..4873fd3 100644 --- a/app/Http/Controllers/App/Mission/EditorController.php +++ b/app/Http/Controllers/App/Mission/EditorController.php @@ -118,13 +118,19 @@ public function create(Request $request, SurveyServiceContract $surveyService, N } $typeKorean = MissionType::getKoreanNames()[$type]; + $data = null; + try { - $date = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', "{$request->get('date')} {$request->get('time')}"); + $dateString = $request->get('date') . ' ' . $request->get('time'); + $date = \Carbon\Carbon::parse($dateString); + + if (!$date->isValid()) { + throw new \Exception('Invalid date/time format'); + } } catch (\Exception $e) { - throw new \Exception('Invalid data/time format', 422); + throw new \Exception('Invalid date/time format', 422); } - if ($date->isPast()) { throw new \Exception('DATE OLD', 422); @@ -209,7 +215,18 @@ public function update(Request $request): JsonResponse } $typeKorean = MissionType::getKoreanNames()[$type]; - $date = \Carbon\Carbon::createFromFormat('Y-m-d H:i', "{$request->get('date')} {$request->get('time')}"); + $data = null; + + try { + $dateString = $request->get('date') . ' ' . $request->get('time'); + $date = \Carbon\Carbon::parse($dateString); + + if (!$date->isValid()) { + throw new \Exception('Invalid date/time format'); + } + } catch (\Exception $e) { + throw new \Exception('Invalid date/time format', 422); + } if ($date->isPast()) {