Exemplo n.º 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";
             }
         }
     }
 }