I have sub category which display all products assigned to it. I want to show all reviews which are belongs to only products in the selected category.
Example: when I open Sub category will show 2 products ( which are assigned to it ) then from table reviews
I want to select all reviews for this products only
So far I have sub category and products. Now I'm wondering how to select those products reviews.
This is what I have in Sub category model for relation with products
public function products()
{
return $this->hasMany('App\Product', 'dual_sub_cat_id');
}
this is the function in my controller
public function showSubProducts($subcatId)
{
$dual = DualSubCategories::where('sub_cat_id', $subcatId)->with('products')->get();
return View::make('subcategory', [
'dual' => $dual
]);
}
In table reviews
I have column for product_id
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iVATlf
via IFTTT
Aucun commentaire:
Enregistrer un commentaire