1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00
laravel-tips/content/tips/use-the-nullordelete-method-in-your-relationship-column-definitions-to-clear-their-value-when-the-parent-record-gets-deleted.md
2021-11-19 16:10:01 +01:00

632 B

title tweet_id thread_slug author_username images created_at slug
Use the nullOrDelete() method in your relationship column definitions to clear their value when the parent record gets deleted 1461703828953198601 weekly-thread-2021-46 mmartin_joo
https://pbs.twimg.com/media/FEQ4DcdXsAcePgo.jpg
2021-11-19T14:32:04+00:00 use-the-nullordelete-method-in-your-relationship-column-definitions-to-clear-their-value-when-the-parent-record-gets-deleted

🔥#Laravel Migration tip🔥

Do you have a relationship that is nullable?

You can use the nullOnDelete() function. It achieves ON DELETE SET NULL behavior: