mardi 18 juin 2019

Laravel - created model id is 0 sometimes (heavy requests)

I've got an ajax call that is basically creating a model A and model B as below:

modela->attr = 'myattr';
modela->save();

modelb->modela_id = modela->id
modelb->attr = 'myattrb';
modelb->save();

Sometimes, the modela->id value is 0 although the model is set as autoincrement. The only pattern I've found is that it fails more often on heavy requests (the client can upload images).

What could be the reasons? Any solution?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire