public function actionStudent() { $query = UserProfile::find()->where(['category_id' => 1]); $searchModel = new UserprofileSearch(); $dataProvider = new ActiveDataProvider(['query' => $query]); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserProfile::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, 'category_id' => $this->category_id, 'confirmed_at' => $this->confirmed_at, 'blocked_at' => $this->blocked_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'flags' => $this->flags]); $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password_hash', $this->password_hash])->andFilterWhere(['like', 'auth_key', $this->auth_key])->andFilterWhere(['like', 'unconfirmed_email', $this->unconfirmed_email])->andFilterWhere(['like', 'registration_ip', $this->registration_ip]); return $dataProvider; }
public function testDeleteOneByGuestUser() { $user = $this->createUser(['user_type' => 'guest']); $userToDelete = $this->createUser(['user_type' => 'guest']); $token = $this->tokenFromUser($user); $this->delete('/users/' . $userToDelete->user_id, [], ['HTTP_AUTHORIZATION' => 'Bearer ' . $token]); $user = User::find($userToDelete->user_id); $profile = UserProfile::find($userToDelete->user_id); $this->assertResponseStatus(403); $this->assertNotNull($user); $this->assertNotNull($profile); }
/** * Lists all UserProfile models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => UserProfile::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }