29 lines
652 B
PHP
29 lines
652 B
PHP
|
<?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();
|
||
|
}
|
||
|
}
|