/** * * @param string $playerName * @return type */ public function showName($playerName) { $sorties = $this->sortieService->getForPlayer($playerName); try { $player = Player::with(['groupedAwards'])->where('playerName', $playerName)->firstOrFail(); } catch (ModelNotFoundException $exception) { // If we can't find that player, but there are sorties available // for them, create a new record for them $player = new Player(); $player->playerName = $playerName; $player->isActive = true; $player->save(); } return view('player.show')->with('player', $player)->with('sorties', $sorties)->with('activity1', $this->generateActivity(1))->with('activity2', $this->generateActivity(2))->with('activity3', $this->generateActivity(3)); }