When retrieving records from the database, sometimes we may require fetching those categories which has product, and this can be achieved by simply. Let's suppose: One to Many relationships between category and products. One to Many relationships between product and feedbacks. $categories = Category::has('products')->get(); But what if we are supposed to retrieve those categories that has product with feedbacks.

Note: You should method named products to define hasMany() relation for product in Category Model and feedbacks method to define hasMany() relation for feedbacks.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners