public function actionList() { $errormsg = ""; $m = new SearchMemberForm(); $m->isexpired = "1"; //默认显示有效会员 $branches = BranchForm::find()->select(['subject', 'id'])->asArray()->all(); $types = array(); $types["-1"] = "全部会员"; foreach ($branches as $branch) { $types[$branch['id']] = $branch['subject']; } $query = MemberForm::find(); $models = $query->orderBy("id DESC"); if ($m->load(Yii::$app->request->post())) { if ($m->branchid > -1) { $models = $models->where(['branchid' => $m->branchid]); } if (isset($m->chinese)) { $models = $models->where(['like', 'chinese', $m->chinese]); } } $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $models->count()]); $models = $models->orderby("id DESC")->offset($pagination->offset)->limit($pagination->limit)->all(); return $this->render("list", ['models' => $models, 'pagination' => $pagination, 'm' => $m, 'types' => $types, 'errormsg' => $errormsg, 'showexpired' => $m->isexpired]); }
public function getBranch() { return $this->hasOne(BranchForm::className(), ['id' => 'branchid']); }
public function actionList() { $query = BranchForm::find(); $models = $query->all(); return $this->render("list", ['models' => $models]); }