Merge pull request #307 from nakazawakan/newbackend

子画面のパスワードリセットをトランザクション化にしました
このコミットが含まれているのは:
chankan77 2022-01-31 15:43:48 +09:00 committed by GitHub
コミット 1ed199cca1
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 4AEE18F83AFDEB23
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' => ['画像の更新に失敗しました。']];
}