Beispiel #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = $this->userRepository->findAll();
     for ($i = 0; $i < 100; $i++) {
         $comment = Comment::inRandomOrder()->first();
         Comment::instantiate($users->random(), $comment, ['body' => $this->faker->text]);
     }
     $comments = Comment::all();
     foreach ($comments as $comment) {
         $comment->refreshScore();
     }
 }
Beispiel #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $users = $this->userRepository->findAll();
     $tags = Tag::get(['id'])->pluck('id')->toArray();
     for ($i = 0; $i < 20; $i++) {
         $user = $users->random();
         $count = mt_rand(1, 2);
         $post = Post::instantiate($user, ['title' => $user->name . '的好贴'], $this->faker->randomElements($tags, $count));
         Comment::instantiate($user, $post, ['body' => $this->faker->text, 'views' => $this->faker->numberBetween(0, 1000)]);
     }
     Post::inRandomOrder()->first()->makeSticky();
 }
Beispiel #3
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $comments = Comment::all();
     $users = $this->userRepository->findAll();
     for ($i = 0; $i < 200; $i++) {
         $up = mt_rand(0, 1);
         if ($up) {
             $users->random()->voteUp($comments->random());
         } else {
             $users->random()->voteDown($comments->random());
         }
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $shops = $this->shopRepository->findAll();
     foreach ($shops as $shop) {
         if ($this->faker->boolean(80)) {
             $this->seed($shop);
         }
     }
     $users = $this->userRepository->findAll();
     foreach ($users as $user) {
         if ($this->faker->boolean(80)) {
             $this->seed($user);
         }
     }
 }
Beispiel #5
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Role::create(['name' => 'owner']);
     $users = $this->userRepository->findAll();
     foreach ($users as $user) {
         if ($this->faker->boolean(50)) {
             $this->seed($user);
         }
     }
     foreach (getTestAccounts() as $testAccount) {
         /** @var User $testUser */
         $testUser = $this->userRepository->findBy('email', $testAccount['email']);
         if (!$testUser->isShopOwner()) {
             $this->seed($testUser);
         }
     }
 }