/** * Updates an existing Auth_assignment model. * If update is successful, the browser will be redirected to the 'view' page. * @param string $item_name * @param string $user_id * @return mixed */ public function actionUpdate($item_name, $user_id) { $model = $this->findModel($item_name, $user_id); $user = User::findByUser_id($user_id); if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('flashupdate', constant('FLASH_UPDATE')); return $this->redirect(['view', 'item_name' => $model->item_name, 'user_id' => $model->user_id]); } else { return $this->render('update', ['model' => $model, 'user' => $user]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = User::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['date_post' => 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; } $query->andFilterWhere(['id' => $this->id, 'u_status' => $this->u_status, 'u_time_link' => $this->u_time_link, 'date_post' => $this->date_post, 'update_post' => $this->update_post]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'u_snp', $this->u_snp])->andFilterWhere(['like', 'u_company', $this->u_company])->andFilterWhere(['like', 'u_activation_link', $this->u_activation_link]); return $dataProvider; }
public function getAuthor() { return $this->hasOne(User::className(), ['id' => 'id_user']); }
/** * Finds the User model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return User the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = User::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getAuthor0() { return $this->hasOne(User::className(), ['id' => 'author_id']); }