Azis Hapidin Seorang Software Developer dengan expertise sebagai Backend Developer, sering membuat REST API dan juga Web-Based Application (Full-Stack). Kadang ngoprek server juga ketika diperlukan.

Laravel Eloquent Filter by Relationship Value

42 sec read


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:

 


Azis Hapidin Seorang Software Developer dengan expertise sebagai Backend Developer, sering membuat REST API dan juga Web-Based Application (Full-Stack). Kadang ngoprek server juga ketika diperlukan.