diff --git a/backend/app/Http/Controllers/Api/FatherRelationsController.php b/backend/app/Http/Controllers/Api/FatherRelationsController.php index da779759..709051dd 100644 --- a/backend/app/Http/Controllers/Api/FatherRelationsController.php +++ b/backend/app/Http/Controllers/Api/FatherRelationsController.php @@ -14,6 +14,14 @@ class FatherRelationsController extends Controller { return ['status_code' => 400, 'error_messages' => ['子の追加に失敗しました。']]; } + $validate = Validator::make($r->all(), [ + 'identity' => 'required|max:20|alpha_num', + ]); + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + if (null === ($child = Child::select('id')->where('identity', $r->identity)->first())) { return ['status_code' => 400, 'error_messages' => ['子の追加に失敗しました。']]; } @@ -43,6 +51,14 @@ class FatherRelationsController extends Controller { return ['status_code' => 400, 'error_messages' => ['子の入社日の更新に失敗しました。']]; } + $validate = Validator::make($r->all(), [ + 'hire_at' => 'date', + ]); + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + $update = [ 'hire_at' => date('Y-m-d H:i:s', strtotime($r->hire_at)), ];