Skip to content

Commit

Permalink
Update EditorController.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Laeng authored Aug 7, 2024
1 parent 969285a commit bdcf611
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions app/Http/Controllers/App/Mission/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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())
{
Expand Down

0 comments on commit bdcf611

Please sign in to comment.