mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 05:14:04 +00:00
15 lines
No EOL
632 B
Markdown
15 lines
No EOL
632 B
Markdown
---
|
|
title: 'Use the nullOrDelete() method in your relationship column definitions to clear their value when the parent record gets deleted'
|
|
tweet_id: '1461703828953198601'
|
|
thread_slug: weekly-thread-2021-46
|
|
author_username: mmartin_joo
|
|
images:
|
|
- 'https://pbs.twimg.com/media/FEQ4DcdXsAcePgo.jpg'
|
|
created_at: 2021-11-19T14:32:04+00:00
|
|
slug: 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: |