🚀 DevOps Certified Professional
📅 Starting: 1st of Every Month 🤝 +91 8409492687 | 🤝 +1 (469) 756-6329 🔍 Contact@DevOpsSchool.com

How to Delete Data in Multiple Tables (with Relationship) Laravel.

DevOps

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

To delete data from the database with a relationship with two tables in Laravel we have to use the solution that I’ve used.

Now, Question is Where and when we use this Method ?

Let’s Discuss, what problems I faced and how Solved it.

In my project, I’ve two Tables in the Database 1st is my Users table where users’ data is stored. 

See the below image:-

And 2nd is SocialProviders where the user’s Provider ID is stored (whenever a user login with Google, Facebook, etc then a unique provider_id is stored to verify the users ) with the user_id to find which provider is for which user. 

See the below image:-

and whenever I Delete a user then I have to delete User data from both the Users table and SocialProviders table for that user.

Now, My problem is that I am not able to delete the User data from the SocialProviders table but the user’s table data is deleted, and when the user re-login with the same Email ID then an error occurs.

Subscribe
Notify of
guest


This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x