I have tables :
products
- id
categories
- id
product_category
- product_id
- category_id
by using eloquent model relation, how to get all product data from a specific category id?
Assuming that you defined relationships on your models, you can try this:
$productName = 'Some product';
$category = Category::findOrFail($categoryId);
$product = $category->products->where('product_name', '=', $productName)->get();
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments