Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Illuminate\Database\Seeder;
- class ProjectsTableSeeder extends Seeder {
- public static $count=1000;
- public function run()
- {
- // Uncomment the below to wipe the table clean before populating
- DB::table('projects')->delete();
- $projects = [];
- $count = self::$count;
- $faker = Faker\Factory::create('sv_SE');
- $faker->seed(rand(0,$count));
- //now, make our data array:
- for ($i=1; $i < $count + 1; $i++) {
- $project = array('name' => $faker->name, 'slug' => $faker->firstName,
- 'created_at' => new DateTime, 'updated_at' => new DateTime);
- $projects[] = $project;
- }
- // Uncomment the below to run the seeder
- DB::table('projects')->insert($projects);
- echo 'Inserted '.$count." projects.\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement