public function search($params) { $query = AuthAssignment::find()->with('user'); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->current->getPageSize()]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['item_name' => $this->item_name, 'user_id' => $this->user_id]); if ($this->created_at) { $interval = Yii::$app->current->getDateInterval($this->created_at); $query->andFilterWhere(['between', 'created_at', $interval[0], $interval[1]]); } return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getAuthAssignment() { return $this->hasOne(AuthAssignment::className(), ['item_name' => 'name']); }
/** * Finds the AuthAssignment model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $item_name * @param integer $user_id * @return AuthAssignment the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($item_name, $user_id) { if (($model = AuthAssignment::findOne(['item_name' => $item_name, 'user_id' => $user_id])) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return AuthAssignment[] */ public function getAuthAssignments() { return $this->hasMany(AuthAssignment::className(), ['user_id' => 'id']); }