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