67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace frontend\models;
|
|
|
|
use Yii;
|
|
use yii\base\Model;
|
|
use yii\data\ActiveDataProvider;
|
|
use common\models\AccountState;
|
|
|
|
/**
|
|
* AccountstateSearch represents the model behind the search form about `common\models\AccountState`.
|
|
*/
|
|
class AccountstateSearch extends AccountState
|
|
{
|
|
/**
|
|
* @inheritdoc
|
|
*/
|
|
public function rules()
|
|
{
|
|
return [
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @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 = AccountState::find();
|
|
|
|
$dataProvider = new ActiveDataProvider([
|
|
'query' => $query,
|
|
'sort' => false
|
|
]);
|
|
|
|
$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->innerJoinWith('account');
|
|
$query->innerJoinWith('account.userAccountAssignments');
|
|
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
|
$query->orderBy( 'created_at desc' );
|
|
|
|
$query->limit = 20;
|
|
|
|
return $dataProvider;
|
|
}
|
|
}
|