personal_area_php/common/services/ProductService.php

30 lines
619 B
PHP
Raw Permalink Normal View History

2024-05-24 15:27:07 +03:00
<?php
namespace common\services;
use common\models\Product;
class ProductService
{
public Product $model;
public function __construct()
{
$this->model = new Product();
}
/**
* @param int $company_id
* @param int|null $category_id
* @return array
*/
public function findBy(int $company_id, int $category_id = null): array
{
return $this->model->find()->where(['company_id' => $company_id])
->andWhere(['status' => Product::STATUS_ACTIVE])
->andFilterWhere(['product_category_id' => $category_id])
->all();
}
}