public function actionProducts($id) { $category = Category::findOne($id); return $category ? $category->getProducts()->all() : array(); }