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


PHP Group::whereName方法代码示例

本文整理汇总了PHP中app\Group::whereName方法的典型用法代码示例。如果您正苦于以下问题:PHP Group::whereName方法的具体用法?PHP Group::whereName怎么用?PHP Group::whereName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\Group的用法示例。


在下文中一共展示了Group::whereName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     DB::table('users')->delete();
     /**
      * faker library
      * 
      * @var 
      */
     $faker = Faker\Factory::create();
     /**
      * fetch id of roles where name is leader
      * 
      * @var integer
      */
     $leaderRole = Role::whereName('leader')->first();
     /**
      * fetch id of roles where name is worker
      * 
      * @var integer
      */
     $workerRole = Role::whereName('worker')->first();
     /**
      * Technical group
      * 
      * @var 
      */
     $technicalGroup = Group::whereName('Technical')->first();
     /**
      * Choir group
      * 
      * @var 
      */
     $choirGroup = Group::whereName('Choir')->first();
     /**
      * Ushering group
      * 
      * @var 
      */
     $usheringGroup = Group::whereName('Ushering')->first();
     /**
      * Populate two technical group leader users
      */
     foreach (range(1, 2) as $value) {
         User::create(['role_id' => $leaderRole->id, 'group_id' => $technicalGroup->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
     }
     /**
      * Populate two choir group leader users
      */
     foreach (range(1, 2) as $value) {
         User::create(['role_id' => $leaderRole->id, 'group_id' => $choirGroup->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
     }
     /**
      * Populate two ushering group leader users
      */
     foreach (range(1, 2) as $value) {
         User::create(['role_id' => $leaderRole->id, 'group_id' => $usheringGroup->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
     }
     /**
      * Populate five technical group worker users
      */
     foreach (range(1, 5) as $value) {
         $user = User::create(['role_id' => $workerRole->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
         $user->groups()->sync([$technicalGroup->id]);
     }
     /**
      * Populate five choir group worker users
      */
     foreach (range(1, 5) as $value) {
         $user = User::create(['role_id' => $workerRole->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
         $user->groups()->sync([$choirGroup->id]);
     }
     /**
      * Populate five ushering group worker users
      */
     foreach (range(1, 5) as $value) {
         $user = User::create(['role_id' => $workerRole->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
         $user->groups()->sync([$usheringGroup->id]);
     }
     /**
      * Populate five ushering and technical group worker users
      */
     foreach (range(1, 5) as $value) {
         $user = User::create(['role_id' => $workerRole->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
         $user->groups()->sync([$usheringGroup->id, $technicalGroup->id]);
     }
     /**
      * Populate five ushering and choir group worker users
      */
     foreach (range(1, 5) as $value) {
         $user = User::create(['role_id' => $workerRole->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
         $user->groups()->sync([$usheringGroup->id, $choirGroup->id]);
     }
     /**
      * Populate five techinal and ushering group worker users
      */
     foreach (range(1, 5) as $value) {
         $user = User::create(['role_id' => $workerRole->id, 'is_verified' => true, 'name' => $faker->name, 'email' => $faker->email, 'password' => 'abc']);
         $user->groups()->sync([$technicalGroup->id, $choirGroup->id]);
     }
 }
开发者ID:agoiabel,项目名称:church-worker-management-app,代码行数:100,代码来源:UsersTableSeeder.php


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