dimanche 13 juin 2021

Use transaction in laravel

I'm creating new user after that sending notification to user, i don't want to send notifications if user not created whether server side error occurs or on failure of database query. I'm trying to use transaction, but do not have idea where to place transaction code so that if user not created then it should not move to next code block.

  $save = new newUser;
    if($save->save()){
    // Notification block
     return response()->json(['status' => true, 'title' => 'Created' , 'message' => 'Data Saved Successfully'],200);
    }
    else
    {
     return response()->json(['status' => false ,'title' => 'Error' , 'message' => 'Data Not Saved'],200);
    }

Any help is highly appreciated



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Supzyx
via IFTTT

Aucun commentaire:

Enregistrer un commentaire