fitness-web/backend/models/InventoryGroupSearch.php

71 lines
1.7 KiB
PHP

<?php
namespace backend\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\InventoryGroup;
/**
* InventoryGroupSearch represents the model behind the search form about `common\models\InventoryGroup`.
*/
class InventoryGroupSearch extends InventoryGroup
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_inventory_group', 'id_product_category', 'status'], 'integer'],
[['name', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = InventoryGroup::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id_inventory_group' => $this->id_inventory_group,
'id_product_category' => $this->id_product_category,
'status' => $this->status,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'name', $this->name]);
return $dataProvider;
}
}