1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 21:34:03 +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

561 B

title tweet_id thread_slug author_username images created_at slug
You can define default model data for BelongsTo relationships 1520040284783972352 weekly-thread-2022-17 cosmeescobedo
https://pbs.twimg.com/media/FQ6XRnBVgAAHT1w.jpg
2022-04-29T14:00:19+00:00 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.