Database Transactions - Automatically Rollback If Something Goes Wrong - Laravel
HTML-код
- Опубликовано: 5 фев 2022
- In this video, we will be looking at how to automatically roll back the database code that has been already executed when something goes wrong. We can make use of database transactions to roll back the changes when something goes wrong. Also there are some things that you need to do when using queues with database transaction. This video will show you in detail about this.
=== Important Links ===
Fonts, extensions I use, and Support Laratips links:
bit.ly/m/laratips
====================== Support ======================
If you want me to continue making this kind of video for free on RUclips, then you can help me financially by sending a few bucks to my Wise (wise.com/invite/u/ashishd233) account in Nepalese 🇳🇵 currency.
My Wise email: ashish.dhamala2015@gmail.com
If you decide to support me, please send me your Twitter handle in the mail so that I can shout out about you.
====================== Social Media Links ======================
Let's be friends
/ aashish_dhamala
====================== Video Related Links ======================
Database transaction documentation link:
laravel.com/docs/8.x/database...
====================== Other Videos ======================
Laravel Package Development Playlist
• Laravel Package Develo...
Password Validation In Laravel with at least one Letters, Numbers, Upper and Lowercase or Symbols:
• Password Validation In...
Multiple Apis With ForwardsCalls Trait And Code Refactoring Tip - Laravel Hidden Feature:
• Multiple Apis With For...
Laravel Chunking - You Might Be Doing This Wrong - Problem and Solution:
• Laravel Chunking - You...
Laravel Tip - Properly Get Data Between Two Dates
• Laravel Tip - Properly...
Get Data From Multiple Databases In One Project | Laravel Tip
• Get Data From Multiple...
========= Theme and Font Used =========
Theme:
Cobalt2 Theme Official (marketplace.visualstudio.com/...)
Font:
JetBrains Mono (www.jetbrains.com/lp/mono/)
====================== Tech stack ======================
Laravel
PHP
#laravel #php #laraveltip #laratips
Really informative
Thanks for sharing.
Great, thank you!.
nice explaination boss
Very informative bro, Keep it up 🤗
Great Video Sir
Nice content as always. Very informative. My question is even if the mail is not queued can afterCommit still stop the sending of mail if error occurs?
I am mot sure about that. Need to check.
Nice tutorial. I'm new subscriber
It’s really helpful.
Dear, please make a video which are changes in Laravel 9.❤️❤️
Coming up next
@@Laratips thanks dear❤️..we are waiting for it..
Thanks
You are welcome
Thank you !
How to proceed if some database insertion is performed in an external service class ? Is there a way to "queue" insertion ?
It doesn't matter where the database insertion is happening. As long as it's inside database transaction, it will get rolled back.
I would recommend not to write DB::transaction inside service class but in controller always. That way you can be consistent.
@@Laratips Ok, but if let's say a Service is responsible for creating roles and permissions, how to proceed ? You send the user transaction to the service inside the DB transaction, and then if permission assignment fails into the service, will the transaction rollback ?
Yes, it will rollback if the service is inside transaction.
@@Laratips Ok thank you very much !
Very interesting. Never used DB Transaction, but I will take into account
Thank you I was not aware about transaction with mail part.
Can you plz make video on bounce mail and unbounced mail part?
Different mail sending services like mailgun, postmark, etc will have hooks where you can add your application url. And let's say when en email is bounced, they will hit the url that you have specified. And you can easily say the mail as bounced by saving bounced info in the database if this url is hit.
Kudos to your dedication !!! it is awesome
Thanks
After commit is available in Observers too
Yes, its available in everything that can be queued.