/**
  * Show the application welcome screen to the user.
  *
  * @return Response
  */
 public function scraper()
 {
     $success = '';
     $groups = Group::lists('name', 'group_id');
     $locations = Location::lists('location', 'location_id');
     //$tournaments = Tournament::orderBy('start_date', 'desc')
     //	->lists('name','tournament_id');
     $tournaments = Tournament::selectRaw('CONCAT(name, " (", start_date, ")") as name, tournament_id')->orderBy('start_date', 'desc')->lists('name', 'tournament_id');
     $players = Player::select('first_name', 'last_name', 'player_id', \DB::raw('CONCAT(first_name, " ", last_name) as full_name'))->orderBy('first_name')->orderBy('last_name')->get()->lists('full_name', 'player_id');
     return view('admin.scraper', compact('groups', 'locations', 'tournaments', 'players', 'success'));
 }
 /**
  * Insert new Match
  *
  * @param  array  $data
  * @return Participant
  */
 public function create_match(array $data)
 {
     $players = Player::select('player_id', 'first_name', 'last_name', \DB::raw('CONCAT(first_name, " ", last_name) as full_name'))->lists('player_id', 'full_name');
     //check to see if players exist in Players table
     $err = '';
     if (!array_key_exists($data['player1'], $players)) {
         $err .= '  Not in Players table: ' . $data['player1'];
     }
     if (!array_key_exists($data['player2'], $players)) {
         $err .= '  Not in Players table: ' . $data['player2'];
     }
     if ($err == '') {
         $player1_id = $players[$data['player1']];
         $player2_id = $players[$data['player2']];
         $match = \DB::table('matches')->where('tournament_id', '=', $data['tournament_id'])->where('player1_id', '=', $player1_id)->where('player2_id', '=', $player2_id)->first();
         if (is_null($match)) {
             $match = Match::create(['player1_id' => $player1_id, 'player2_id' => $player2_id, 'winner_id' => $player1_id, 'tournament_id' => $data['tournament_id'], 'match_date' => $data['match_date'], 'match_type' => $data['match_type'], 'match_division' => $data['match_division']]);
         }
     }
 }