guild/backend/modules/accesses/models/AccessesSearch.php

81 lines
2.1 KiB
PHP
Raw Normal View History

2019-10-22 18:03:40 +03:00
<?php
namespace app\modules\accesses\models;
2020-02-04 12:17:14 +03:00
use common\classes\Debug;
2019-10-22 18:03:40 +03:00
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Accesses;
/**
* AccessesSearch represents the model behind the search form of `common\models\Accesses`.
*/
class AccessesSearch extends Accesses
{
2020-02-04 12:17:14 +03:00
public $fio;
2019-10-22 18:03:40 +03:00
/**
* {@inheritdoc}
*/
public function rules()
{
return [
[['id'], 'integer'],
2020-02-04 12:17:14 +03:00
[['name', 'login', 'password', 'link', 'project', 'info', 'fio'], 'safe'],
2019-10-22 18:03:40 +03:00
];
}
/**
* {@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)
{
2020-02-04 12:17:14 +03:00
//Debug::dd($params);
$query = Accesses::find()
->leftJoin('user_card_accesses', 'accesses.id = user_card_accesses.accesses_id')
->leftJoin('user_card', 'user_card_accesses.user_card_id = user_card.id')
->orderBy('user_card.fio asc');
2019-10-22 18:03:40 +03:00
// add conditions that should always apply here
$dataProvider = new ActiveDataProvider([
2020-02-04 12:17:14 +03:00
'query' => $query
2019-10-22 18:03:40 +03:00
]);
$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,
]);
$query->andFilterWhere(['like', 'name', $this->name])
2020-01-21 17:33:07 +03:00
->andFilterWhere(['like', 'login', $this->login])
->andFilterWhere(['like', 'password', $this->password])
->andFilterWhere(['like', 'link', $this->link])
->andFilterWhere(['like', 'project', $this->project])
->andFilterWhere(['like', 'info', $this->info]);
2019-10-22 18:03:40 +03:00
return $dataProvider;
}
}