子画面のパスワードリセットをトランザクション化にしました

このコミットが含まれているのは:
守矢諏訪子 2022-01-31 15:41:01 +09:00
コミット 8df5aca418
1個のファイルの変更15行の追加2行の削除

ファイルの表示

@ -276,15 +276,27 @@ class ChildrenController extends Controller {
try {
// DBに入る又は変えります。
TelActivation::where('child_id', $result->id)->delete();
TelActivation::create($create);
DB::beginTransaction();
$telact = TelActivation::where('child_id', $result->id);
$telac2 = new TelActivation;
if (null !== ($telact->first())) {
$telact->delete();
}
$telac2->fill($create);
$telac2->push();
// SMSを送ります。
$message = view('sms.children.password', ['token' => $token]);
\Notification::route('nexmo', '81'.substr($r->tel, 1))->notify(new SmsNotification($message));
DB::commit();
} catch (\Throwable $e) {
// 失敗
Log::critical($e->getMessage());
DB::rollback();
return ['status_code' => 400, 'error_messages' => '電話番号が未登録です。入力した情報を確認してください。'];
}
@ -507,6 +519,7 @@ class ChildrenController extends Controller {
// 失敗
Log::critical($e->getMessage());
Storage::disk('private')->delete($filename);
DB::rollback();
return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']];
}