vendredi 29 juin 2018

Laravel creating multiple entries same time

When some users trying to hit the signup button they are getting integrity constrain error,

$user = User::where("username", $username)->first(); if(is_null($user)){ $user = new User; } ...

This code is not actually validating because, i am getting a simultaneous request, so both the requests are trying to create the user with same username. when i removed the unique constrain for testing, i found duplicated users. I have added a button disable functionality on submit but the issue still exists.

So in short

  1. Users trying to signup
  2. In controller I am getting 2 requests same time , both request are trying to create the same user.

is there any way I can handle the issue ?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire