53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Leagues;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Controllers\Leagues;
|
|
|
|
use Auth;
|
|
use App\Season;
|
|
use App\Round;
|
|
use App\leagues\League;
|
|
|
|
class LeagueController extends Controller
|
|
{
|
|
public function index($season_id) {
|
|
|
|
if (Auth::guest()) { return redirect("/"); }
|
|
if (!Auth::user()->admin) { return redirect("/"); }
|
|
|
|
$season = Season::where('id','=',$season_id)->first();
|
|
$rounds = Round::where('season_id','=',$season_id)->orderBy('id')->get();
|
|
|
|
$league = League::where('season_id','=',$season_id)->first();
|
|
|
|
$start_round_name="Einstellen";
|
|
$start_round_id=-1;
|
|
if ($league) {
|
|
if ($league->start_round_id) {
|
|
$startRound = Round::where('id','=',$league->start_round_id)->first();
|
|
$start_round_name = $startRound->name;
|
|
$start_round_id = $startRound->id;
|
|
}
|
|
}
|
|
|
|
$startRound=array();
|
|
$startRound['id'] = $start_round_id;
|
|
$startRound['name'] = $start_round_name;
|
|
|
|
// Fetch existing leagues
|
|
|
|
// No leagues: Create Qualification League or Standard League System (including matches)
|
|
// necessary input: start_round(_id), round_count
|
|
|
|
// Delete all leagues & matches
|
|
|
|
//
|
|
|
|
|
|
return view('leagues.index', compact('season','rounds','startRound'));
|
|
}
|
|
}
|