first commit
This commit is contained in:
28
frontend/controllers/ProductController.php
Executable file
28
frontend/controllers/ProductController.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user