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 have a product with feedback?

$cateogries= Category::has('products.feedbacks')->get();

It's that easy.

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

Reference:
One to Many
Query Relationship