/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Adminlog::find(); $query->select(['wolf_admin_log.*', 'a.name', 'a.email']); $query->with('admin'); $query->leftJoin('wolf_admin a', 'a.id = wolf_admin_log.admin_id'); $query->orderBy("login_time DESC"); $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; } $query->andFilterWhere(['id' => $this->id, 'admin_id' => $this->admin_id, 'login_time' => $this->login_time]); $query->andFilterWhere(['like', 'ip_address', $this->ip_address]); // $query->andFilterWhere(['like', 'admin.name', $this->admin->name]); // echo $query->createCommand()->getRawSql();exit; return $dataProvider; }
/** * Finds the Adminlog model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Adminlog the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Adminlog::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }