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/when-a-relationship-is-already-loaded-and-cached-on-the-model-instance-youll-have-to-refresh-it.md
2021-04-06 18:27:18 +02:00

566 B

title tweet_id thread_slug author_username images created_at slug
When a relationship is already loaded and "cached" on the model instance, you'll have to refresh it 1308084124947820554 1-rt-1-tip samuelstancl
https://pbs.twimg.com/media/Eic_JawXgAAEbYL.png
2021-04-06T16:07:40+00:00 when-a-relationship-is-already-loaded-and-cached-on-the-model-instance-youll-have-to-refresh-it

$domain->refresh(); to refresh its attributes

$tenant->load('primary_domain'); to update the primary_domain relationship on the $tenant instance