Пример #1
0
 public function actionFollowRefresh()
 {
     Follow::deleteAll(['status' => [self::USER_STATUS_TEST_ACTIVE, self::USER_STATUS_TEST_INACTIVE]]);
     $users = User::find()->active(self::USER_STATUS_TEST_ACTIVE)->all();
     /* @var $users User[] */
     $count = count($users);
     foreach ($users as $user) {
         $number = $this->faker->numberBetween(1, $count);
         for ($i = 0; $i < $number; $i++) {
             $recipient = $users[$this->faker->numberBetween(0, $count - 1)];
             if ($recipient->guid == $user->guid) {
                 continue;
             }
             $follow = $user->createFollow($recipient, $this->faker->name, $this->faker->numberBetween() % 2 == 0);
             if (!$follow->save()) {
                 echo $user->id . ' -> ' . $recipient->id . "\n";
             }
         }
     }
 }
Пример #2
0
 /**
  * Get list of contacts.
  */
 public function actionList()
 {
     $pageSize = Yii::$app->request->post('pageSize');
     $currentPage = Yii::$app->request->post('currentPage');
     return Follow::findAllByIdentityInBatch($pageSize, $currentPage);
 }
Пример #3
0
 /**
  * Get the query of the users who is following me.
  * @return BaseUserQuery
  */
 public function getFollowers()
 {
     $model = Follow::buildNoInitModel();
     return $this->hasMany(User::className(), [$this->guidAttribute => $model->createdByAttribute])->via('inverseFollows');
 }