예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Friend::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'friend_id' => $this->friend_id, 'status' => $this->status, 'number_meetings' => $this->number_meetings, 'is_favorite' => $this->is_favorite, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     return $dataProvider;
 }
예제 #2
0
 public static function getFriendList($user_id)
 {
     // load user's friends into email list array for autocomplete
     $friend_list = \frontend\models\Friend::find()->where(['user_id' => $user_id])->all();
     $email_list = [];
     foreach ($friend_list as $x) {
         $email_list[] = $x->friend->email;
     }
     return $email_list;
 }