本文整理匯總了PHP中app\Item::truncate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::truncate方法的具體用法?PHP Item::truncate怎麽用?PHP Item::truncate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Item
的用法示例。
在下文中一共展示了Item::truncate方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::statement("SET foreign_key_checks = 0");
Item::truncate();
DB::statement("SET foreign_key_checks = 1");
$cause = Cause::where('cause_title', 'Liberation of minor sex')->get()->first();
Item::create(['cause_id' => $cause->cause_id, 'item_name' => 'blanket', 'item_description' => 'for minor sex', 'item_required' => 20, 'item_received' => 7, 'item_worth' => 11]);
Item::create(['cause_id' => $cause->cause_id, 'item_name' => 'bedsheets', 'item_description' => 'for minor sex', 'item_required' => 45, 'item_received' => 23, 'item_worth' => 9]);
$cause = Cause::where('cause_title', 'Child Support')->get()->first();
Item::create(['cause_id' => $cause->cause_id, 'item_name' => 'books', 'item_description' => 'for child support', 'item_required' => 200, 'item_received' => 159, 'item_worth' => 14]);
Item::create(['cause_id' => $cause->cause_id, 'item_name' => 'desks', 'item_description' => 'for child support', 'item_required' => 100, 'item_received' => 67, 'item_worth' => 15]);
// $cause = Cause::where('cause_title',
// 'Flood Donation PK')->get()->first();
// Item::create([
// 'cause_id' => $cause->cause_id,
// 'item_name' => 'blanket',
// 'item_description' => 'for flood donation',
// 'item_required' => 500,
// 'item_received' => 322,
// 'item_worth' => 12
// ]);
// Item::create([
// 'cause_id' => $cause->cause_id,
// 'item_name' => 'clothes',
// 'item_description' => 'for flood donation',
// 'item_required' => 900,
// 'item_received' => 545,
// 'item_worth' => 15
// ]);
// $cause = Cause::where('cause_title',
// 'Earthquake PK')->get()->first();
// Item::create([
// 'cause_id' => $cause->cause_id,
// 'item_name' => 'cash',
// 'item_description' => 'for earthquake',
// 'item_required' => 500000,
// 'item_received' => 123410,
// 'item_worth' => 1
// ]);
// Item::create([
// 'cause_id' => $cause->cause_id,
// 'item_name' => 'clothes',
// 'item_description' => 'for earthquake',
// 'item_required' => 100,
// 'item_received' => 67,
// 'item_worth' => 15
// ]);
}
開發者ID:umarhussain15,項目名稱:web_semester_project_integration_repo_Jan16,代碼行數:53,代碼來源:ItemTableSeeder.php
示例2: run
public function run()
{
Item::truncate();
factory(App\Item::class, 12)->create();
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Item::truncate();
$data = [['type_id' => 1, 'name' => "cánh rồng", 'image_url' => 'images/items/canh.jpg']];
Item::insert($data);
}