function generate() { $min = Input::get('min'); $max = Input::get('max'); if ($min >= $max) { echo "<script type='text/javascript'>alert('Max should be greater than min! Try again.')</script>"; //$msg = "try again bitch"; return redirect('admin/generate')->withErrors(['Max should be greater than min! Try again.', 'The Message']); } Team::truncate(); // drop all team data $numTeams = AdminController::findNumTeams($max, $min); AdminController::initTeams($numTeams); $teams = AdminController::createTeamArr($numTeams); $usersWeights = AdminController::populateUserWeights(); AdminController::distribute($usersWeights, $teams, $max); return redirect('/admin'); }