Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2.  
  3. use Illuminate\Database\Seeder;
  4.  
  5. class ProjectsTableSeeder extends Seeder {
  6.  
  7.     public static $count=1000;
  8.     public function run()
  9.     {
  10.         // Uncomment the below to wipe the table clean before populating
  11.         DB::table('projects')->delete();
  12.  
  13.         $projects = [];
  14.         $count = self::$count;
  15.         $faker = Faker\Factory::create('sv_SE');
  16.         $faker->seed(rand(0,$count));
  17.  
  18.         //now, make our data array:
  19.         for ($i=1; $i < $count + 1; $i++) {
  20.             $project = array('name' => $faker->name, 'slug' => $faker->firstName,
  21.                         'created_at' => new DateTime, 'updated_at' => new DateTime);
  22.             $projects[] = $project;
  23.  
  24.         }
  25.  
  26.         // Uncomment the below to run the seeder
  27.         DB::table('projects')->insert($projects);
  28.         echo 'Inserted '.$count." projects.\n";
  29.     }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement