/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); $tags = Tag::all(); $skills = Skill::all(); for ($i = 0; $i < 50; $i++) { $user = User::register($faker->unique()->userName, $faker->unique()->email, bcrypt('password'), 'talent'); $this->userRepository->save($user); $profileData = ['first_name' => $faker->firstName, 'last_name' => $faker->lastName, 'location' => $faker->city, 'describe' => $faker->numberBetween(1, count($skills) - 1), 'about' => $faker->sentence(), 'facebook' => $faker->userName, 'linked_in' => $faker->userName, 'twitter' => $faker->userName, 'meetup' => $faker->userName, 'published' => $faker->boolean()]; $userSkills = ''; foreach (range(1, rand(2, 4)) as $x) { $id = rand(1, count($tags) - 1); $userSkills .= $tags[$id]->name . ","; } $profileData['skills'] = $userSkills; $this->dispatcher->dispatch(new UpdateProfile($user, $profileData)); } }
/** * Run the database seeds. * * @return void */ public function run() { $faker = Faker\Factory::create(); $slugify = Slugify::create(); $users = User::all(); $tags = Tag::all(); $skills = Skill::all(); foreach ($users as $user) { foreach (range(1, rand(2, 3)) as $i) { $name = $faker->name; $startup = Startup::create(['name' => $name, 'description' => $faker->text, 'url' => $slugify->slugify($name), 'user_id' => $user->id, 'published' => true]); $this->repository->save($startup); $startupTags = []; foreach (range(1, rand(2, 4)) as $i) { $id = rand(1, count($tags) - 1); $startupTags[] = $id; } $needs = []; $commitments = ['full-time', 'part-time']; foreach (range(1, rand(2, 3)) as $i) { $roleId = rand(1, count($skills) - 1); $needTags = []; foreach (range(1, rand(2, 3)) as $i) { $id = rand(1, count($tags) - 1); $needTags[] = $id; } $needs[] = array('role' => $roleId, 'quantity' => rand(1, 10), 'skills' => implode(',', $needTags), 'commitment' => $commitments[rand(0, 1)], 'desc' => $faker->text); $this->repository->updateNeeds($startup, $needs); } $startup->tags()->attach($startupTags); foreach (range(1, rand(2, 3)) as $i) { $id = rand(1, count($users) - 1); if ($startup->owner->id !== $id) { $this->repository->addMemberRequest($users[$id], $startup, false); if (rand(0, 1)) { $this->repository->approveMemberRequest($users[$id], $startup, false); } } } } } }