Added HTML Helpers from Laravelcollective
This commit is contained in:
parent
0736ecf29f
commit
b5c1f40a45
31 changed files with 614 additions and 220 deletions
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use Illuminate\Http\Request;
|
||||
use App\Season;
|
||||
use App\Round;
|
||||
use App\Game;
|
||||
use DB;
|
||||
|
||||
class RoundsController extends Controller
|
||||
|
|
@ -25,4 +26,96 @@ class RoundsController extends Controller
|
|||
//return view('rounds.index');
|
||||
//return view ('welcome');
|
||||
}
|
||||
|
||||
|
||||
public function create() {
|
||||
$currentSeason = Season::getCurrent();
|
||||
if ($currentSeason) {
|
||||
return view('rounds.create', compact('currentSeason'));
|
||||
}
|
||||
redirect()->home()->withErrors('Es muss zuerst eine Saison angelegt werden');
|
||||
}
|
||||
|
||||
|
||||
public function store() {
|
||||
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'name' => 'required',
|
||||
'game1_team1' => 'required',
|
||||
'game1_team2' => 'required',
|
||||
'game1_kickoff' => 'required',
|
||||
'game2_team1' => 'required',
|
||||
'game2_team2' => 'required',
|
||||
'game2_kickoff' => 'required',
|
||||
'game3_team1' => 'required',
|
||||
'game3_team2' => 'required',
|
||||
'game3_kickoff' => 'required',
|
||||
'game4_team1' => 'required',
|
||||
'game4_team2' => 'required',
|
||||
'game4_kickoff' => 'required'
|
||||
]);
|
||||
|
||||
$seasonId = Season::getCurrent()->id;
|
||||
|
||||
$round = Round::create([
|
||||
'name' => request('name'),
|
||||
'season_id' => $seasonId
|
||||
]);
|
||||
$round->save();
|
||||
$round_id = $round->id;
|
||||
|
||||
$game1 = Game::create([
|
||||
'round_id' => $round_id,
|
||||
'team1' => request('game1_team1'),
|
||||
'team2' => request('game1_team2'),
|
||||
'kickoff' => request('game1_kickoff')
|
||||
]);
|
||||
|
||||
$game2 = Game::create([
|
||||
'round_id' => $round_id,
|
||||
'team1' => request('game2_team1'),
|
||||
'team2' => request('game2_team2'),
|
||||
'kickoff' => request('game2_kickoff')
|
||||
]);
|
||||
|
||||
$game3 = Game::create([
|
||||
'round_id' => $round_id,
|
||||
'team1' => request('game3_team1'),
|
||||
'team2' => request('game3_team2'),
|
||||
'kickoff' => request('game3_kickoff')
|
||||
]);
|
||||
|
||||
$game4 = Game::create([
|
||||
'round_id' => $round_id,
|
||||
'team1' => request('game4_team1'),
|
||||
'team2' => request('game4_team2'),
|
||||
'kickoff' => request('game4_kickoff')
|
||||
]);
|
||||
// Sign them in
|
||||
|
||||
// Redirect to the home page
|
||||
return redirect()->home();
|
||||
}
|
||||
|
||||
public function editname($round_id)
|
||||
{
|
||||
$round = Round::where('id', $round_id)->first();
|
||||
return view('rounds.editname', compact('round'));
|
||||
}
|
||||
|
||||
public function storename()
|
||||
{
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'round_id' => 'required',
|
||||
'name' => 'required'
|
||||
]);
|
||||
|
||||
$round = Round::where('id', request('round_id'))->first();
|
||||
$round->name = request('name');
|
||||
$round->save();
|
||||
|
||||
return redirect('/rounds');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue