本文整理匯總了PHP中app\models\Project::truncate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Project::truncate方法的具體用法?PHP Project::truncate怎麽用?PHP Project::truncate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Project
的用法示例。
在下文中一共展示了Project::truncate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Project::truncate();
Timer::truncate();
$faker = Faker::create();
$john = User::where('name', 'John')->first();
$payee_john = Payee::find($john->id);
$payer_john = Payer::find($john->id);
$jenny = User::where('name', 'Jenny')->first();
$jane = User::where('name', 'Jane')->first();
$bob = User::where('name', 'Bob')->first();
$payee_bob = Payee::find($bob->id);
/**
* John is payee
*/
// dd($faker->randomElement([1,2,3]));
// dd($faker->randomElement($payee_john->payers()->lists('id')));
// dd($payee_john->payers()->lists('id')->all());
foreach (range(0, 2) as $index) {
$project = Project::create(['payee_id' => $john->id, 'payer_id' => $faker->randomElement($payee_john->payers()->lists('id')->all()), 'description' => $faker->word, 'rate_per_hour' => 40, 'status' => 'confirmed']);
$this->createTimersForProject($project);
}
//Create a project with Jenny as payer
$project = Project::create(['payee_id' => $john->id, 'payer_id' => $jenny->id, 'description' => $faker->word, 'rate_per_hour' => 40, 'status' => 'confirmed']);
$this->createTimersForProject($project);
/**
* John is payer
*/
foreach (range(0, 2) as $index) {
$project = Project::create(['payee_id' => $faker->randomElement($payer_john->payees()->lists('id')->all()), 'payer_id' => $john->id, 'description' => $faker->word, 'rate_per_hour' => 1, 'status' => 'confirmed']);
$this->createTimersForProject($project);
}
/**
* Bob is payee
*/
foreach (range(0, 4) as $index) {
$project = Project::create(['payee_id' => $bob->id, 'payer_id' => $jenny->id, 'description' => $faker->word, 'rate_per_hour' => 40, 'status' => 'confirmed']);
$this->createTimersForProject($project);
}
/**
* Jenny is payee
*/
foreach (range(0, 2) as $index) {
$project = Project::create(['payee_id' => $jenny->id, 'payer_id' => $john->id, 'description' => $faker->word, 'rate_per_hour' => 10, 'status' => 'confirmed']);
$this->createTimersForProject($project);
}
}