当前位置: 首页>>代码示例>>PHP>>正文


PHP Project::truncate方法代码示例

本文整理汇总了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);
     }
 }
开发者ID:JennySwift,项目名称:project-tracker,代码行数:52,代码来源:ProjectSeeder.php


注:本文中的app\models\Project::truncate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。