Added HTML Helpers from Laravelcollective
This commit is contained in:
parent
0736ecf29f
commit
b5c1f40a45
31 changed files with 614 additions and 220 deletions
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class GameController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
43
pfosten/app/Http/Controllers/GamesController.php
Normal file
43
pfosten/app/Http/Controllers/GamesController.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Game;
|
||||
use Carbon\Carbon;
|
||||
|
||||
class GamesController extends Controller
|
||||
{
|
||||
public function edit($game_id) {
|
||||
$game=Game::where('id',$game_id)->first();
|
||||
//$testdate=str_replace(' UTC ','T',date('Y-m-d h:m'));
|
||||
|
||||
return view('games.edit',compact('game'));
|
||||
}
|
||||
|
||||
public function store() {
|
||||
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'id' => 'required',
|
||||
'team1' => 'required',
|
||||
'team2' => 'required',
|
||||
'score1' => 'required',
|
||||
'score2' => 'required',
|
||||
'kickoff' => 'required'
|
||||
]);
|
||||
|
||||
// Fetch, modify, save game
|
||||
$game = Game::where('id', request('id'))->first(); // Only for editing existing. New games get created in RoundsController.
|
||||
$game->team1 = request('team1');
|
||||
$game->team2 = request('team2');
|
||||
$game->score1= request('score1');
|
||||
$game->score2= request('score2');
|
||||
$game->kickoff=request('kickoff');
|
||||
$game->save();
|
||||
|
||||
// Redirect to the Rounds Index
|
||||
return redirect('/rounds');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,25 +4,22 @@ namespace App\Http\Controllers;
|
|||
|
||||
use Illuminate\Http\Request;
|
||||
use App\User;
|
||||
use App\Season;
|
||||
use App\Payment;
|
||||
use DB;
|
||||
|
||||
class UsersController extends Controller
|
||||
{
|
||||
public function main() {
|
||||
return view('main');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$users = DB::table('users')->get();
|
||||
$users = DB::table('users')->where('deleted',null)->get();
|
||||
return view('users.index', compact('users'));
|
||||
}
|
||||
|
||||
|
||||
public function mypage() {
|
||||
return view('mypage');
|
||||
}
|
||||
|
||||
public function getAllUsersAsJson() {
|
||||
$users = DB::table('users')->get();
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function showUsers() {
|
||||
$users = DB::table('users')->get();
|
||||
return view('users.list', compact('users'));
|
||||
|
|
@ -36,4 +33,46 @@ class UsersController extends Controller
|
|||
//$user = DB::table('users')->find($id);
|
||||
return view('users.show', compact('userObject'));
|
||||
}
|
||||
|
||||
|
||||
public function edit($user_id) {
|
||||
$user = User::where('id',$user_id)->first();
|
||||
$season_id = Season::getCurrent()->id;
|
||||
|
||||
$paid_date_str="";
|
||||
$val=User::payment_date($user_id, $season_id);
|
||||
if ($val) { $paid_date_str=$val;}
|
||||
|
||||
return view ('users.edit', compact('user','paid_date_str'));
|
||||
}
|
||||
|
||||
public function store() {
|
||||
$season_id = Season::getCurrent()->id;
|
||||
|
||||
// Validate form
|
||||
$this->validate(request(), [
|
||||
'id' => 'required',
|
||||
'name' => 'required',
|
||||
'email'=> 'required'
|
||||
]);
|
||||
|
||||
// Create and save the season
|
||||
|
||||
$user=User::where('id', request('id'))->first();
|
||||
|
||||
$user->name=request('name');
|
||||
$user->email=request('email');
|
||||
|
||||
if (request()->has('admin')) { $user->admin=request('admin'); }
|
||||
$user->save();
|
||||
|
||||
|
||||
if (request()->has('paid')) {
|
||||
Payment::set_payment_date(request('id'), $season_id, request('paid'));
|
||||
}
|
||||
|
||||
// Redirect to the home page
|
||||
return redirect('/users');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue