/** * Execute the command. * * @param StartupRepository $repository * @return static */ public function handle(StartupRepository $repository) { if (false === $this->startup->hasMember($this->user)) { $repository->addMemberRequest($this->user, $this->startup); } return $this->startup; }
/** * Execute the command. * * @param StartupRepository $repository * @return static */ public function handle(StartupRepository $repository) { if ($this->startup->hasMember($this->user)) { $repository->cancelMembershipRequest($this->user, $this->startup); } return $this->startup; }
/** * Execute the command. * * @param StartupRepository $repository * @return static */ public function handle(StartupRepository $repository) { switch ($this->action) { case 'approve': $repository->approveMemberRequest($this->user, $this->startup); Flash::message("Congratulations! {$this->user->profile->first_name} {$this->user->profile->last_name} has been accepted into your startup!"); break; case 'reject': $repository->rejectMemberRequest($this->user, $this->startup); Flash::message("{$this->user->profile->first_name} {$this->user->profile->last_name} has been rejected from your startup!"); break; } return $this->startup; }
/** * Execute the command. * * @param StartupRepository $repository * @return Startup */ public function handle(StartupRepository $repository) { $startup = Startup::updateStartup($this->startup, $this->data); $repository->save($startup); if (isset($this->data['tags'])) { $repository->updateTags($startup, $this->data['tags']); } if (isset($this->data['needs'])) { $repository->updateNeeds($startup, $this->data['needs']); } if (isset($this->data['image'])) { $repository->updateImage($startup, $this->data['image']); } return $startup; }
/** * Execute the command. * * @param StartupRepository $repository * @return static */ public function handle(StartupRepository $repository) { $slugify = Slugify::create(); $startup = Startup::create(['user_id' => $this->user->id, 'name' => $this->startup->name, 'description' => $this->startup->description, 'url' => $slugify->slugify($this->startup->name), 'stage_id' => $this->startup->stage_id, 'video' => $this->startup->video, 'published' => true]); $repository->save($startup); if (isset($this->startup->tags)) { $repository->updateTags($startup, $this->startup->tags); } if (isset($this->startup->needs)) { $repository->updateNeeds($startup, $this->startup->needs); } if (isset($this->startup->image)) { $repository->updateImage($startup, $this->startup->image); } return $startup; }
/** * 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); } } } } } }
/** * Show the application welcome screen to the user. * * @param StartupRepository $startupRepository * @param UserRepository $userRepository * @return Response */ public function index(StartupRepository $startupRepository, UserRepository $userRepository) { $startups = $startupRepository->allActive(null, null, DB::raw('RAND()'), 2); $talent = $userRepository->findActiveTalents(null, null, null, DB::raw('RAND()'), 2); return view('welcome')->with('startups', $startups)->with('talents', $talent); }
/** * Index that shows all active startups. * * @return Response */ public function index() { $startups = $this->repository->allActive(Input::get('tag'), Input::get('needs')); $needs = Skill::lists('name', 'id')->all(); return view('startups.index')->with('startups', $startups)->with('needs', $needs); }