本文整理匯總了PHP中app\Item::store方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::store方法的具體用法?PHP Item::store怎麽用?PHP Item::store使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Item
的用法示例。
在下文中一共展示了Item::store方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$item1 = ItemInfo::create(['name' => 'lucky charms']);
$item2 = ItemInfo::create(['name' => 'chicken']);
$item3 = ItemInfo::create(['name' => 'coke']);
$item4 = ItemInfo::create(['name' => 'frozen pizza']);
$item5 = ItemInfo::create(['name' => 'sprite']);
$item6 = ItemInfo::create(['name' => 'pepsi']);
$item7 = ItemInfo::create(['name' => 'mtn dew']);
$item8 = ItemInfo::create(['name' => 'crackers']);
$item9 = ItemInfo::create(['name' => 'breakfast bar']);
$item10 = ItemInfo::create(['name' => 'shrimp']);
$item11 = ItemInfo::create(['name' => 'hot dogs']);
$item12 = ItemInfo::create(['name' => 'hot dog buns']);
$item13 = ItemInfo::create(['name' => 'mustard']);
$item14 = ItemInfo::create(['name' => 'pickle']);
$item15 = ItemInfo::create(['name' => 'banana']);
$item16 = ItemInfo::create(['name' => 'apple']);
$item17 = ItemInfo::create(['name' => 'bacon']);
$item18 = ItemInfo::create(['name' => 'hot pocket']);
$item19 = ItemInfo::create(['name' => 'orange juice']);
$item20 = ItemInfo::create(['name' => 'candy']);
$items = [$item1, $item2, $item3, $item4, $item5, $item6, $item7, $item8, $item9, $item10, $item11, $item12, $item13, $item14, $item15, $item16, $item17, $item18, $item19, $item20];
$stores = Store::all();
/* Generate these 4 items for each store with random prices between
$1.00 and $6.00 (100 - 600 in DB)
*/
foreach ($stores as $store) {
foreach ($items as $item) {
$i = new Item();
$i->price = rand(100, 600);
$i->store()->associate($store);
$i->itemInfo()->associate($item);
$i->save();
}
}
}