本文整理汇总了PHP中Vendor::services方法的典型用法代码示例。如果您正苦于以下问题:PHP Vendor::services方法的具体用法?PHP Vendor::services怎么用?PHP Vendor::services使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vendor
的用法示例。
在下文中一共展示了Vendor::services方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: vendor
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;
}