/**
  * @inheritdoc
  */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($this->isActive()) {
         \Yii::$app->user->login($this);
     }
 }
 /**
  * Searches users.
  * @param array $params search query data
  * @return ActiveDataProvider
  */
 public function search($params = [])
 {
     $query = parent::search();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andWhere(['owner_id' => $this->owner_id])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
 /**
  * @inheritdoc
  */
 public function search($params = [])
 {
     $query = parent::search();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'subject', $this->subject])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'model_class', $this->model_class])->andFilterWhere(['like', 'model_event', $this->model_event]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params = [])
 {
     $query = parent::search();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['start_at' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'owner_id' => $this->owner_id, 'model_class' => $this->model_class, 'model_id' => $this->model_class, 'model_method' => $this->model_class, 'model_value' => $this->model_class, 'interval' => $this->interval]);
     $query->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(start_at), "%Y-%m-%d")', $this->start_at])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(end_at), "%Y-%m-%d")', $this->end_at]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params = [])
 {
     $query = parent::search();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         $query->andFilterWhere(['status' => $this->status]);
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['status' => $this->status])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
 /**
  * Searches users.
  * @param array $params search query data
  * @return ActiveDataProvider
  */
 public function search($params = [])
 {
     $query = parent::search();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['status' => $this->status])->andFilterWhere(['like', 'id', $this->id])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(created_at), "%Y-%m-%d")', $this->created_at])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(updated_at), "%Y-%m-%d")', $this->updated_at]);
     if ($this->role) {
         $query->andWhere(['id' => \Yii::$app->authManager->getUserIdsByRole($this->role)]);
     }
     return $dataProvider;
 }
 /**
  * @inheritdoc
  */
 public function search($params = [])
 {
     $query = parent::search();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'owner_id' => $this->owner_id, 'parent_id' => $this->parent_id, 'branch_id' => $this->branch_id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'parent_class', $this->parent_class])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(created_at), "%Y-%m-%d")', $this->created_at])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(updated_at), "%Y-%m-%d")', $this->updated_at]);
     return $dataProvider;
 }
 /**
  * Searches models.
  * @param array $params search params
  * @return \yii\data\ActiveDataProvider dataProvider
  */
 public function search($params = [])
 {
     $t = parent::tableName();
     $query = parent::search();
     $query->orderBy(["{$t}.log_time" => SORT_DESC]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere([$t . '.id' => $this->id, $t . '.level' => $this->level]);
     $query->andFilterWhere(['like', $t . '.category', $this->category])->andFilterWhere(['like', $t . '.prefix', $this->prefix])->andFilterWhere(['like', $t . '.message', $this->message]);
     if ($this->log_time) {
         $query->andWhere("DATE_FORMAT(FROM_UNIXTIME({$t}.log_time), '%Y-%m-%d') = :logTime")->addParams([':logTime' => $this->log_time]);
     }
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params = [])
 {
     $query = parent::search();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'owner_id' => $this->owner_id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'brief', $this->brief])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'DATE_FORMAT(FROM_UNIXTIME(created_at), "%Y-%m-%d")', $this->created_at]);
     if ($this->category_id) {
         $t = $this->tableName();
         $query->joinWith("categoryToItems", true, "LEFT JOIN")->andWhere(["category_id" => $this->category_id])->groupBy("{$t}.id");
     }
     return $dataProvider;
 }
예제 #10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params = [])
 {
     $query = parent::search();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     $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, 'user_id' => $this->user_id, 'owner_id' => $this->owner_id, 'model_id' => $this->model_id]);
     $query->andFilterWhere(['like', 'event', $this->event])->andFilterWhere(['like', 'model_name', $this->model_name])->andFilterWhere(['like', 'message', $this->message]);
     if ($this->created_at) {
         $query->andWhere("DATE_FORMAT(FROM_UNIXTIME(created_at), '%Y-%m-%d') = :created_at")->addParams([':created_at' => $this->created_at]);
     }
     return $dataProvider;
 }
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return array_merge(parent::attributeLabels(), ['rememberMe' => Yii::t('modules/user', 'Remember me')]);
 }