mirror of
https://github.com/archtechx/laravel-tips.git
synced 2025-12-12 21:34:03 +00:00
13 lines
538 B
Markdown
13 lines
538 B
Markdown
---
|
|
title: 'Use whereBelongsTo() and relation()->is() instead of comparing ids manually'
|
|
tweet_id: '1466810182265032710'
|
|
thread_slug: weekly-thread-2021-48
|
|
author_username: archtechx
|
|
images:
|
|
- 'https://pbs.twimg.com/media/FFXqNWlVUAElTew.jpg'
|
|
created_at: 2021-12-03T16:42:54+00:00
|
|
slug: use-wherebelongsto-and-relation-is-instead-of-comparing-ids-manually
|
|
---
|
|
🔥 Tip: You don't have to use "related_id"-type columns in database queries or value comparisons.
|
|
|
|
Laravel understands your relations and lets you write much cleaner code.
|