Beispiel #1
0
 public static function vendor()
 {
     $faker = Faker\Factory::create();
     $image_urls = array('http://i.imgur.com/Gh4ZX.png', 'http://i.imgur.com/vySFV.png', 'http://i.imgur.com/RdBae.png', 'http://i.imgur.com/ED5fa.png', 'http://i.imgur.com/gJncN.png', 'http://i.imgur.com/3pKFS.png', 'http://i.imgur.com/3pKFS.png');
     $u = User::create(array('email' => 'vendor' . self::$vendor_count . '@example.com', 'password' => 'password'));
     $v = new Vendor(array('company_name' => $faker->company, 'contact_name' => $faker->name, 'address' => $faker->streetAddress, 'city' => $faker->city, 'state' => $faker->stateAbbr, 'zip' => $faker->postcode, 'ballpark_price' => rand(1, 4), 'image_url' => $image_urls[array_rand($image_urls)], 'homepage_url' => $faker->url, 'more_info' => $faker->paragraph));
     $v->user_id = $u->id;
     $v->save();
     foreach (Service::all() as $service) {
         if (rand(1, 2) == 2) {
             $v->services()->attach($service->id);
         }
     }
     self::$vendor_count++;
     return $v;
 }