/** * Lists all Product models. * @return mixed */ public function actionIndex() { $query = UserAccount::find(); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => Yii::$app->params['pagination']]); $models = $query->offset($pages->offset)->limit($pages->limit)->all(); return $this->render('index', ['models' => $models, 'pages' => $pages]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserAccount::find(); $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, 'photo_id' => $this->photo_id, 'gender' => $this->gender, 'date_of_birth' => $this->date_of_birth, 'token_expired' => $this->token_expired, 'last_activity' => $this->last_activity, 'state' => $this->state, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'firstname', $this->firstname])->andFilterWhere(['like', 'lastname', $this->lastname])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'about', $this->about])->andFilterWhere(['like', 'facebook_url', $this->facebook_url])->andFilterWhere(['like', 'token', $this->token]); return $dataProvider; }
/** * Updates an existing Region model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post())) { $model->updated_at = date("Y-m-d H:i:s"); if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->redirect(['update', 'id' => $model->id]); } } else { $user = UserAccount::find()->select('id, username')->all(); $regions = Region::find()->select('id,title')->all(); return $this->render('update', ['user' => $user, 'model' => $model, 'regions' => $regions]); } }
/** * Updates an existing UserAuthorize model. * If update is successful, the browser will be redirected to the 'view' page. * @param string $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $account = UserAccount::findOne($id); $user = UserAccount::find()->select('id, username')->all(); $role = UserRole::find()->select('id,role_name')->all(); if ($model->load(Yii::$app->request->post())) { $model->updated_at = date("Y-m-d H:i:s"); if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { // print_r($model->errors); return $this->render('update', ['model' => $model, 'user' => $user, 'role' => $role, 'account' => $account]); } } else { // print_r($model->errors); return $this->render('update', ['model' => $model, 'user' => $user, 'role' => $role, 'account' => $account]); } }
/** * Updates an existing Customer model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); $user = UserAccount::find()->select('id, username')->all(); if ($model->load(Yii::$app->request->post())) { echo $model->email; echo $model->username; $model->updated_at = date("Y-m-d H:i:s"); $model->token_expired = date('Y-m-d H:i:s', strtotime($model->token_expired)); if ($model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { // print_r($model->errors); return $this->render('update', ['model' => $model, 'user' => $user]); } } else { return $this->render('update', ['model' => $model, 'user' => $user]); } }
public function getCreater() { return $this->hasOne(UserAccount::className(), ['id' => 'created_by']); }
public function getUser() { return $this->hasOne(UserAccount::className(), ['id' => 'user_id']); }
/** * Finds the UserAccount model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UserAccount the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserAccount::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }