public function decklist($link, $id) { $data['page'] = "tournaments"; $data['ranking'] = \MtgSlo\Ranking::find($id); return view("decklist", $data); }
public function processResults() { if (\Input::file("file")) { if (!\Input::file("file")->isValid()) { return "You have uploaded invalid file."; } else { if (\Input::file("file")->getClientOriginalExtension() == "wer" && \Input::file("file")->getClientMimeType() == "application/octet-stream") { $this->rankings()->delete(); $xml = simplexml_load_file(\Input::file("file")); foreach ($xml->participation->team as $team) { $players[(string) $team->member['person']]['name'] = (string) $team['name']; } foreach ($xml->matches->round as $round) { foreach ($round->match as $match) { switch ((string) $match['outcome']) { case '1': if (!isset($players[(string) $match['person']]['mp'])) { $players[(string) $match['person']]['mp'] = 3; } else { $players[(string) $match['person']]['mp'] += 3; } break; case '2': if (!isset($players[(string) $match['person']]['mp'])) { $players[(string) $match['person']]['mp'] = 1; } else { $players[(string) $match['person']]['mp'] += 1; } break; case '3': if (!isset($players[(string) $match['person']]['mp'])) { $players[(string) $match['person']]['mp'] = 3; } else { $players[(string) $match['person']]['mp'] += 3; } break; } } } foreach ($players as $dci => &$player) { $dc = (string) $dci; $full = explode(", ", $player['name']); $ime = $full[1] . " " . $full[0]; if (isset($player['mp'])) { $mp = $player['mp']; } else { $mp = 0; } foreach ($xml->participation->role->ref as $role) { if ($role['person'] == $dci) { $place = $role['seq']; } } \MtgSlo\Ranking::create(array("id_tournament" => $this->id, "dci" => $dc, "place" => $place, "points" => $mp, "leaguepoints" => $mp, "full_name" => $ime)); } return "Results are successfully uploaded."; } else { return "You have uploaded invalid file."; } } } else { return "You have uploaded invalid file."; } }
public static function all($columns = array()) { return Ranking::where("decklist", "<>", "")->get(); }