PostTagTableSeeders.php 369 B

1234567891011121314151617181920212223
  1. <?php
  2. use Illuminate\Database\Seeder;
  3. class PostTagTableSeeder extends Seeder {
  4. public function run()
  5. {
  6. for($i = 1; $i <= 100; ++$i)
  7. {
  8. $numbers = range(1, 20);
  9. shuffle($numbers);
  10. $n = rand(3, 6);
  11. for($j = 1; $j < $n; ++$j)
  12. {
  13. DB::table('post_tag')->insert(array(
  14. 'post_id' => $i,
  15. 'tag_id' => $numbers[$j]
  16. ));
  17. }
  18. }
  19. }
  20. }