From c552b78e4318e431f61b420f9223e14957811b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Sun, 6 Feb 2022 16:11:38 +0900 Subject: [PATCH] =?UTF-8?q?=E5=AD=90=E3=81=AE=E3=83=91=E3=82=B9=E3=83=AF?= =?UTF-8?q?=E3=83=BC=E3=83=89=E3=83=AA=E3=82=BB=E3=83=83=E3=83=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/ChildrenController.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/backend/app/Http/Controllers/Api/ChildrenController.php b/backend/app/Http/Controllers/Api/ChildrenController.php index 0848da70..e96cf1f0 100644 --- a/backend/app/Http/Controllers/Api/ChildrenController.php +++ b/backend/app/Http/Controllers/Api/ChildrenController.php @@ -613,15 +613,23 @@ class ChildrenController extends Controller { return ['status_code' => 422, 'error_messages' => $validate->errors()]; } - $update = [ - 'password' => Hash::make($r->password), - ]; - try { - Child::where('id', (int)$child_id)->update($update); + DB::beginTransaction(); + + $child = Child::find((int)$child_id); + $child->password = Hash::make($r->password); + $child->save(); + + if (isset($r->token)) { + $telact = TelActivation::where('token', $r->token); + $telact->delete(); + } + + DB::commit(); } catch (\Throwable $e) { // 失敗 Log::critical($e->getMessage()); + DB::rollback(); return ['status_code' => 400, 'error_messages' => ['パスワードの更新に失敗しました。']]; }