IOP-Patho/frontend/modules/patho/models/ToolInOutSearch.php

80 lines
2.2 KiB
PHP

<?php
namespace frontend\modules\patho\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\ToolInOut;
/**
* ToolInOutSearch represents the model behind the search form of `common\models\ToolInOut`.
*/
class ToolInOutSearch extends ToolInOut
{
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id', 'tool_id', 'amount', 'price', 'want_amount'], 'integer'],
[['durable_date_in', 'durable_detail_add', 'durable_method', 'durable_budget_type', 'want', 'durable_place', 'durable_date_use'], '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 = ToolInOut::find();
// add conditions that should always apply here
$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;
}
// grid filtering conditions
$query->andFilterWhere([
'id' => $this->id,
'tool_id' => $this->tool_id,
'durable_date_in' => $this->durable_date_in,
'amount' => $this->amount,
'price' => $this->price,
'want_amount' => $this->want_amount,
'durable_date_use' => $this->durable_date_use,
]);
$query->andFilterWhere(['like', 'durable_detail_add', $this->durable_detail_add])
->andFilterWhere(['like', 'durable_method', $this->durable_method])
->andFilterWhere(['like', 'durable_budget_type', $this->durable_budget_type])
->andFilterWhere(['like', 'want', $this->want])
->andFilterWhere(['like', 'durable_place', $this->durable_place]);
return $dataProvider;
}
}