Laravel Eloquent Filter by Relationship Value

Use Laravel relationship for filtering data.

Laravel Eloquent Filter by Relationship Value

Let’s say we have a User Model like this:

Based on the User model above, the relationship from User to Phone is One to Many. This means 1 User can have many phones. And then, how to get a User who has a specific phone?

For example, we want to get users who have a phone with brand = Samsung. The query is like this: