TagTableSeeders.php 488 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. use Illuminate\Database\Seeder;
  3. use Carbon\Carbon;
  4. class TagTableSeeder extends Seeder {
  5. private function randDate()
  6. {
  7. return Carbon::createFromDate(null, rand(1, 12), rand(1, 28));
  8. }
  9. public function run()
  10. {
  11. DB::table('tags')->delete();
  12. for($i = 0; $i < 20; ++$i)
  13. {
  14. $date = $this->randDate();
  15. DB::table('tags')->insert(array(
  16. 'tag' => 'tag' . $i,
  17. 'tag_url' => 'tag' . $i,
  18. 'created_at' => $date,
  19. 'updated_at' => $date
  20. ));
  21. }
  22. }
  23. }