mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 21:34:03 +00:00
15 lines
No EOL
561 B
Markdown
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. |