本文整理汇总了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);
}
}