1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 05:14:04 +00:00
laravel-tips/content/tips/you-can-define-default-model-data-for-belongsto-relationships.md
Samuel Štancl 23979938b4 Week 17/2022
2022-04-29 21:07:03 +02:00

15 lines
No EOL
561 B
Markdown

---
title: 'You can define default model data for BelongsTo relationships'
tweet_id: '1520040284783972352'
thread_slug: weekly-thread-2022-17
author_username: cosmeescobedo
images:
- 'https://pbs.twimg.com/media/FQ6XRnBVgAAHT1w.jpg'
created_at: 2022-04-29T14:00:19+00:00
slug: you-can-define-default-model-data-for-belongsto-relationships
---
🔥 Laravel Tip: Default Models.
In your relationships, you can define default models.
That way if the relationship doesn't exist it will return a default model so you don't have to check if is null every time.