Example #1
0
 /**
  * Run the database seeds.
  */
 public function run()
 {
     // Seed normal topics
     $topics = factory(PHPHub\Topic::class)->times(100)->make();
     $user_ids = User::lists('id')->toArray();
     $node_ids = Node::lists('id')->toArray();
     foreach ($topics as $topic) {
         $topic->user_id = array_rand($user_ids, 1);
         $topic->node_id = array_rand($node_ids, 1);
         $this->dispatch(new SaveTopic($topic));
     }
     // Seed excellent topics
     $topics = factory(PHPHub\Topic::class)->times(20)->make();
     foreach ($topics as $topic) {
         $topic->user_id = array_rand($user_ids, 1);
         $topic->node_id = array_rand($node_ids, 1);
         $topic->is_excellent = true;
         $this->dispatch(new SaveTopic($topic));
     }
     // Seed wiki topics
     $topics = factory(PHPHub\Topic::class)->times(20)->make();
     foreach ($topics as $topic) {
         $topic->user_id = array_rand($user_ids, 1);
         $topic->node_id = array_rand($node_ids, 1);
         $topic->is_wiki = true;
         $this->dispatch(new SaveTopic($topic));
     }
 }
Example #2
0
 /**
  * Run the database seeds.
  */
 public function run()
 {
     $replies = factory(PHPHub\Reply::class)->times(1000)->make();
     $user_ids = User::lists('id')->toArray();
     $topic_ids = Topic::lists('id')->toArray();
     foreach ($replies as $reply) {
         $reply->user_id = array_rand($user_ids, 1);
         $reply->topic_id = array_rand($topic_ids, 1);
         $reply->save();
     }
 }
Example #3
0
 /**
  * Run the database seeds.
  */
 public function run()
 {
     // Seed normal topics
     $normal_topics = factory(PHPHub\Topic::class)->times(100)->make();
     $wiki_topics = factory(PHPHub\Topic::class, 'wiki')->times(20)->make();
     $excellent_topics = factory(PHPHub\Topic::class, 'excellent')->times(20)->make();
     $topics = array_merge($normal_topics->all(), $wiki_topics->all(), $excellent_topics->all());
     $user_ids = User::lists('id')->toArray();
     $node_ids = Node::lists('id')->toArray();
     foreach ($topics as $topic) {
         $topic->user_id = array_rand($user_ids, 1);
         $topic->node_id = array_rand($node_ids, 1);
         $this->dispatch(new SaveTopic($topic));
     }
 }