Exemple #1
1
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 1; $i <= 100; $i++) {
         DB::table('users')->insert(['userName' => str_replace('.', '_', $faker->unique()->userName), 'email' => $faker->email, 'password' => bcrypt('password'), 'state' => 'active', 'roleId' => 1, 'passwordEpochUpdatedAt' => time(), 'created_at' => time(), 'updated_at' => time()]);
         DB::table('businesses')->insert(['name' => $faker->company, 'type' => $faker->catchPhrase, 'about' => 'We are ' . $faker->company . ' ' . $faker->companySuffix . '. We\'re working ' . $faker->bs . '.', 'phone' => $faker->phoneNumber, 'website' => $faker->domainName, 'serviceCoverage' => 'Servicing ' . $i, 'created_at' => time(), 'updated_at' => time()]);
         DB::table('userDetails')->insert(['userId' => $i, 'name' => $faker->name, 'location' => $faker->streetAddress, 'profilePicPath' => '/images/small/' . rand(1, 10) . 's.jpg', 'coverPicPath' => '/images/large/' . rand(1, 10) . 'l.jpg', 'about' => Faker\Provider\Lorem::sentence($nbWords = 30), 'type' => Faker\Provider\Lorem::sentence($nbWords = 2), 'businessId' => $i]);
     }
     for ($i = 101; $i <= 103; $i++) {
         DB::table('users')->insert(['userName' => 'user' . ($i - 100), 'email' => 'useremail' . ($i - 100) . '@horsify.com', 'password' => bcrypt('password'), 'state' => 'active', 'roleId' => 1, 'passwordEpochUpdatedAt' => time(), 'created_at' => time(), 'updated_at' => time()]);
         DB::table('businesses')->insert(['name' => 'Business ' . ($i - 100), 'type' => $faker->catchPhrase, 'about' => 'We are ' . $faker->company . ' ' . $faker->companySuffix . '. We\'re working ' . $faker->bs . '.', 'phone' => $faker->phoneNumber, 'website' => $faker->domainName, 'serviceCoverage' => 'Servicing ' . ($i - 100), 'created_at' => time(), 'updated_at' => time()]);
         DB::table('userDetails')->insert(['userId' => $i, 'name' => 'User ' . ($i - 100), 'location' => $faker->streetAddress, 'profilePicPath' => '/images/small/' . rand(1, 10) . 's.jpg', 'coverPicPath' => '/images/large/' . rand(1, 10) . 'l.jpg', 'about' => Faker\Provider\Lorem::sentence($nbWords = 30), 'type' => Faker\Provider\Lorem::sentence($nbWords = 2), 'businessId' => $i]);
     }
     for ($i = 104; $i <= 150; $i++) {
         DB::table('users')->insert(['userName' => 'user' . ($i - 100), 'email' => 'useremail' . ($i - 100) . '@horsify.com', 'password' => bcrypt('password'), 'state' => 'active', 'roleId' => 1, 'passwordEpochUpdatedAt' => time(), 'created_at' => time(), 'updated_at' => time()]);
         DB::table('userDetails')->insert(['userId' => $i, 'name' => 'User ' . ($i - 100), 'location' => $faker->streetAddress, 'profilePicPath' => '/images/small/' . rand(1, 10) . 's.jpg', 'coverPicPath' => '/images/large/' . rand(1, 10) . 'l.jpg', 'about' => Faker\Provider\Lorem::sentence($nbWords = 30), 'type' => Faker\Provider\Lorem::sentence($nbWords = 2), 'businessId' => 0]);
     }
     DB::table('photoAlbums')->insert(['user_id' => 1, 'type' => 'album', 'name' => 'Album 1', 'path' => '/images/photos-1.png', 'active' => TRUE, 'linkWith' => 2, 'about' => 'Horse Trading & Farming 1', 'created_at' => time(), 'updated_at' => time()]);
     DB::table('photoAlbums')->insert(['user_id' => 1, 'type' => 'album', 'name' => 'Album 2', 'path' => '/images/photos-2.png', 'active' => TRUE, 'linkWith' => 0, 'about' => 'Horse Trading & Farming 2', 'created_at' => time(), 'updated_at' => time()]);
     DB::table('photoAlbums')->insert(['user_id' => 1, 'type' => 'album', 'name' => 'Album 3', 'path' => '/images/photos-3.png', 'active' => TRUE, 'linkWith' => 1, 'about' => 'Horse Trading & Farming 3', 'created_at' => time(), 'updated_at' => time()]);
     DB::table('photoAlbums')->insert(['user_id' => 1, 'type' => 'photo', 'name' => 'Photo 1', 'path' => '/images/bg.jpg', 'active' => TRUE, 'linkWith' => 1, 'about' => 'This is Photo 1', 'created_at' => time(), 'updated_at' => time()]);
     DB::table('photoAlbums')->insert(['user_id' => 1, 'type' => 'photo', 'name' => 'Photo 2', 'path' => '/images/bg.jpg', 'active' => TRUE, 'linkWith' => 1, 'about' => 'This is Photo 2', 'created_at' => time(), 'updated_at' => time()]);
     DB::table('photoAlbums')->insert(['user_id' => 1, 'type' => 'photo', 'name' => 'Photo 3', 'path' => '/images/bg.jpg', 'active' => TRUE, 'linkWith' => 3, 'about' => 'This is Photo 1 of this album', 'created_at' => time(), 'updated_at' => time()]);
 }
 public function run()
 {
     DB::table('products')->truncate();
     $faker = Faker\Factory::create();
     $lorem = new Faker\Provider\Lorem($faker);
     $random = new Faker\Provider\Base($faker);
     for ($i = 0; $i < 500; $i++) {
         $name = $lorem->word();
         $product = new Product();
         $product->slug = Str::slug($name);
         $product->name = ucfirst($name);
         $product->price = $random->randomNumber(2);
         $product->save();
     }
 }