Hi everyone,
i have to table in my database categories(id,name) and products(id,price,name,category_id) and i made a join query in CategoriesController :
public function actionCommand()
{
$categories = Categories::find()->joinWith('products')->all();
return $this->render('command', ['categories'=>$categories]);
}
and i display them in the categories\command view :
foreach ($categories as $category){
echo $category->name;
}
now i want to display all the products for a specific category and i dont’t know how.
Please help me if anyone can