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]); } }