la_back/frontend/controllers/ProductController.php
2023-11-21 19:51:44 +03:00

29 lines
652 B
PHP
Executable File

<?php
namespace frontend\controllers;
use common\models\Product;
/**
* Product controller
*/
class ProductController extends BaseApiController
{
public function actionGetByCategoryId($category_id)
{
return Product::find()
->where(['status' => Product::STATUS_ACTIVE, 'category_id' => $category_id])
->select(['id', 'name', 'description', 'price'])
->all();
}
public function actionGetById($id)
{
return Product::find()
->where(['status' => Product::STATUS_ACTIVE, 'id' => $id])
->select(['id', 'name', 'description', 'price'])
->one();
}
}