Working on Leagues: Adding migrations, controllers, views

This commit is contained in:
Torsten 2017-09-08 16:22:40 +02:00
parent 50cc4c75bf
commit 7bfba61602
16 changed files with 8788 additions and 33 deletions

8486
d0274241_2017-09-08_1023.sql Normal file

File diff suppressed because it is too large Load diff

View file

@ -55,6 +55,7 @@ class RegistrationController extends Controller
$user->save();
auth()->login($user);
\App\Tipp::createAllTips();
// Redirect to the home page
return redirect()->home();

View file

@ -139,8 +139,6 @@ class RoundsController extends Controller
}
public function editname($round_id)
{
$round = Round::where('id', $round_id)->first();

View file

@ -346,7 +346,6 @@ class UsersController extends Controller
return ($rank1[1] < $rank2[1]);
}
public function show_payouts() {
$currentSeason = Season::getCurrent();

View file

@ -204,7 +204,7 @@ class Tipp extends Model
}
}
public static function createAllTips(){
public static function createAllTips() {
$users = DB::table('users')->where('deleted',null)->get();
foreach($users as $user) {
Tipp::createTipps($user->id);

View file

@ -0,0 +1,47 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateLeaguesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('leagues', function (Blueprint $table) {
$table->increments('id');
$table->integer('season_id');
$table->integer('rank');
$table->integer('subrank');
$table->string('name');
$table->boolean('is_qualification');
$table->integer('start_round_id');
$table->integer('round_count');
$table->timestamps();
});
Schema::create('leagues_members', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->integer('league_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('leagues');
Schema::dropIfExists('leagues_members');
}
}

View file

@ -0,0 +1,35 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateMatchesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('leagues_matches', function (Blueprint $table) {
$table->increments('id');
$table->integer('league_id');
$table->integer('round_id');
$table->integer('user1_id');
$table->integer('user2_id');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('league_matches');
}
}

View file

@ -0,0 +1,52 @@
/* Dropdown Button */
.dropbtn {
/*
background-color: #337ab7;
border-color: #2e6da4;
*/
background-color: white;
border-color: #2e6da4;
color: black;
padding: 4px;
font-size: 14px;
border: 1px solid transparent;
border-color:grey;
border-radius: 4px;
cursor: pointer;
}
/* Dropdown button on hover & focus */
.dropbtn:hover, .dropbtn:focus {
border-color: #337ab7;
background-color: lightgray;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: white;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 2px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #f1f1f1}
/* Show the dropdown menu (use JS to add this class to the .dropdown-content container when the user clicks on the dropdown button) */
.show {display:block;}

View file

@ -30,7 +30,7 @@ return [
'array' => 'The :attribute must have between :min and :max items.',
],
'boolean' => 'The :attribute field must be true or false.',
'confirmed' => 'The :attribute confirmation does not match.',
'confirmed' => 'Die :attribute Eingaben stimmen nicht überein.',
'date' => 'The :attribute is not a valid date.',
'date_format' => 'The :attribute does not match the format :format.',
'different' => 'The :attribute and :other must be different.',

View file

@ -11,6 +11,7 @@
<!-- Custom styles for this template -->
<link href="/css/album.css" rel="stylesheet">
<link href="/css/dropdown.css" rel="stylesheet">
</head>

View file

@ -5,19 +5,24 @@
@if (Auth::check())
<a class="lead" href="/">Start</a> &nbsp; &nbsp; &nbsp;
@if (Auth::user()->admin)
<a class="lead" href="/seasons">Saison</a> &nbsp; &nbsp; &nbsp;
<a class="lead" href="/rounds#{{\App\Round::getFirstIncompleteRound()}}">Runden</a> &nbsp; &nbsp; &nbsp;
<a class="lead" href="/users">Spieler</a> &nbsp; &nbsp; &nbsp;
<a class="lead" href="/roundmails">Rundmail</a> &nbsp; &nbsp; &nbsp;
<div>
<label class="lead" style="font-color: black; font-weight: bold; font-size: 14px; ">Admin:</label>
<a class="lead" href="/seasons">Saison</a> &nbsp;
<a class="lead" href="/rounds#{{\App\Round::getFirstIncompleteRound()}}">Runden</a> &nbsp;
<a class="lead" href="/users">Spieler</a> &nbsp;
<a class="lead" href="/roundmails">Rundmail</a> &nbsp;
</div>
@endif
<a class="lead" href="/users/show_payouts">Quoten</a> &nbsp; &nbsp; &nbsp;
<a class="lead" href="/users/payout#playerid_{{Auth::user()->id}}">Geldrangliste</a> &nbsp; &nbsp; &nbsp;
<a class="lead" href="/tipps#{{\App\Round::getFirstTippableRound()->id}}">Tipps</a> &nbsp; &nbsp; &nbsp;
<a class="lead" href="/users/ranking/roundid_-1#playerid_{{Auth::user()->id}}" >Rangliste</a> &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;
<a class="lead" href="/">Start</a> &nbsp;
<a class="lead" href="/users/show_payouts">Quoten</a> &nbsp;
<a class="lead" href="/tipps#{{\App\Round::getFirstTippableRound()->id}}">Tipps</a> &nbsp;
<a class="lead" href="/users/ranking/roundid_-1#playerid_{{Auth::user()->id}}" >Rangliste</a> &nbsp;
<a class="lead" href="/users/payout#playerid_{{Auth::user()->id}}">Geldrangliste</a> &nbsp;
<label class="lead text ml-auto" >Spieler: <a href="/users/useredit/{{ Auth::user()->id }}">{{ Auth::user()->name }}</a></label><a class="lead" href="/logout">(abmelden)</a>
@endif
</div>

View file

@ -0,0 +1,87 @@
@extends('layouts.layout')
@section('content')
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<section class="jumbotron text-center">
<div class="container">
<h2>Liga-Spiel Einstellungen</h2>
<h2 style="width: 400px;">{{ $season->name }}</h2>
<p>&nbsp;</p>
<h3>Startrunde:</h3>
<form>
<div class="dropdown">
<button onclick="toggleDropdown('dropdown_startround'); return false;" class="dropbtn">{{$startRound['name']}}</button>
<div id="dropdown_startround" class="dropdown-content">
@foreach($rounds as $round)
<a onclick="false;" href="/league_settings/set_start_round/roundid_{{ $round->id }}">{{ $round->name }}</a>
@endforeach
</div>
</div>
<h3>Anzahl Runden:</h3>
<input></input>
<h3>Liga-Modus</h3>
<div class="dropdown">
<button onclick="toggleDropdown('dropdown_leaguemode'); return false;" class="dropbtn">Modus einstellen</button>
<div id="dropdown_leaguemode" class="dropdown-content">
<a onclick="false;" href="">Qualifikation</a>
<a onclick="false;" href="">Liga-Spiel</a>
</div>
</div>
<p>&nbsp;</p>
<div >
<button class="btn btn-primary">Liga neu erzeugen</button>
</div>
</form>
</div>
</section>
<script>
// When the user clicks on the button,toggle between hiding and showing the dropdown content
function toggleDropdown($elementName) {
document.getElementById($elementName).classList.toggle("show");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
event.cancelBubble=true;
event.cancel();
}
</script>
@endsection

View file

@ -0,0 +1,43 @@
@extends('layouts.layout')
@section('content')
<div class="container">
<h2>Liga-Spiel Einstellungen</h2>
<div class="lead">{{ $season->name }}</div>
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Dropdown</button>
<div id="myDropdown" class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
</div>
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
// Close the dropdown menu if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}
</script>
@endsection

View file

@ -15,7 +15,7 @@
Route::get('/','UsersController@main')->name('home');
Route::get('/register','RegistrationController@create');
Route::get('/register','RegistrationController@create')->name('register');
Route::post('/register','RegistrationController@store');
Route::get('/login','SessionsController@create')->name('login');
@ -63,31 +63,20 @@ Route::get('/roundmails/show/{mail_id}','RoundmailController@show');
Route::post('/roundmails/send','RoundmailController@send');
Route::get('/roundmails/checkReminder','RoundmailController@checkReminder');
// php artisan route:list
//Auth::routes();
Route::post('/password/email','Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
Route::get('/password/reset','Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
Route::get('/password/reset/{token}','Auth\ResetPasswordController@showResetForm')->name('password.reset');
Route::post('/password/reset','Auth\ResetPasswordController@reset');
Route::get('/register','Auth\RegisterController@showRegistrationForm')->name('register');
// replaced by custom version, see route above
//Route::get('/register','Auth\RegisterController@showRegistrationForm')->name('register');
Route::get('/users/send_reset_links_from_settings','UsersController@send_reset_links_from_settings');
//Route::get('/resetpassword','Auth\ResetPasswordController@showResetForm');
//Route::get('test','UsersController@test');
/*
Route::get('/reset','UsersController@reset')->name('password.email');
Route::post('/reset','UsersController@processReset')->name('password.request');
*/
//Route::get('/password/reset','Auth\ForgotPasswordController@showLinkRequestForm')->name('password.request');
//Route::post('/password/email','Auth\ForgotPasswordController@sendResetLinkEmail')->name('password.email');
//Route::get('/abc','Auth\ForgotPasswordController@abc');
//Auth::routes();
Route::get('/home', 'UsersController@main')->name('home');
Route::get('/league_settings/{season_id}','Leagues\LeagueController@index');

View file

@ -6,8 +6,8 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'AddLeagueInfoToSeasons' => $baseDir . '/database/migrations/2017_09_08_095815_add_league_info_to_seasons.php',
'AddReminderfieldToUsers' => $baseDir . '/database/migrations/2017_08_28_110358_add_reminderfield_to_users.php',
'AddRoundCountToSeasonsTable' => $baseDir . '/database/migrations/2017_08_30_102708_add_round_count_to_seasons_table.php',
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Game' => $baseDir . '/app/Game.php',
@ -18,6 +18,8 @@ return array(
'App\\Http\\Controllers\\Controller' => $baseDir . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\GamesController' => $baseDir . '/app/Http/Controllers/GamesController.php',
'App\\Http\\Controllers\\HomeController' => $baseDir . '/app/Http/Controllers/HomeController.php',
'App\\Http\\Controllers\\Leagues\\LeagueController' => $baseDir . '/app/Http/Controllers/Leagues/LeagueController.php',
'App\\Http\\Controllers\\Leagues\\MatchController' => $baseDir . '/app/Http/Controllers/Leagues/MatchController.php',
'App\\Http\\Controllers\\PaymentController' => $baseDir . '/app/Http/Controllers/PaymentController.php',
'App\\Http\\Controllers\\RegistrationController' => $baseDir . '/app/Http/Controllers/RegistrationController.php',
'App\\Http\\Controllers\\RoundmailController' => $baseDir . '/app/Http/Controllers/RoundmailController.php',
@ -46,6 +48,8 @@ return array(
'App\\Setting' => $baseDir . '/app/Setting.php',
'App\\Tipp' => $baseDir . '/app/Tipp.php',
'App\\User' => $baseDir . '/app/User.php',
'App\\leagues\\League' => $baseDir . '/app/leagues/League.php',
'App\\leagues\\Match' => $baseDir . '/app/leagues/Match.php',
'Carbon\\Carbon' => $vendorDir . '/nesbot/carbon/src/Carbon/Carbon.php',
'Carbon\\CarbonInterval' => $vendorDir . '/nesbot/carbon/src/Carbon/CarbonInterval.php',
'Carbon\\Exceptions\\InvalidDateException' => $vendorDir . '/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php',
@ -57,6 +61,8 @@ return array(
'Collective\\Html\\HtmlFacade' => $vendorDir . '/laravelcollective/html/src/HtmlFacade.php',
'Collective\\Html\\HtmlServiceProvider' => $vendorDir . '/laravelcollective/html/src/HtmlServiceProvider.php',
'CreateGamesTable' => $baseDir . '/database/migrations/2017_06_19_112641_create_games_table.php',
'CreateLeaguesTable' => $baseDir . '/database/migrations/2017_09_08_095721_create_leagues_table.php',
'CreateMatchesTable' => $baseDir . '/database/migrations/2017_09_08_095740_create_matches_table.php',
'CreatePasswordResetsTable' => $baseDir . '/database/migrations/2014_10_12_100000_create_password_resets_table.php',
'CreatePaymentsTable' => $baseDir . '/database/migrations/2017_06_19_112638_create_payments_table.php',
'CreateQuotasTable' => $baseDir . '/database/migrations/2017_08_16_164654_create_quotas_table.php',

View file

@ -278,8 +278,8 @@ class ComposerStaticInita19fb0695e1b61b4feeb3cc3fbdd2feb
);
public static $classMap = array (
'AddLeagueInfoToSeasons' => __DIR__ . '/../..' . '/database/migrations/2017_09_08_095815_add_league_info_to_seasons.php',
'AddReminderfieldToUsers' => __DIR__ . '/../..' . '/database/migrations/2017_08_28_110358_add_reminderfield_to_users.php',
'AddRoundCountToSeasonsTable' => __DIR__ . '/../..' . '/database/migrations/2017_08_30_102708_add_round_count_to_seasons_table.php',
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\\Game' => __DIR__ . '/../..' . '/app/Game.php',
@ -290,6 +290,8 @@ class ComposerStaticInita19fb0695e1b61b4feeb3cc3fbdd2feb
'App\\Http\\Controllers\\Controller' => __DIR__ . '/../..' . '/app/Http/Controllers/Controller.php',
'App\\Http\\Controllers\\GamesController' => __DIR__ . '/../..' . '/app/Http/Controllers/GamesController.php',
'App\\Http\\Controllers\\HomeController' => __DIR__ . '/../..' . '/app/Http/Controllers/HomeController.php',
'App\\Http\\Controllers\\Leagues\\LeagueController' => __DIR__ . '/../..' . '/app/Http/Controllers/Leagues/LeagueController.php',
'App\\Http\\Controllers\\Leagues\\MatchController' => __DIR__ . '/../..' . '/app/Http/Controllers/Leagues/MatchController.php',
'App\\Http\\Controllers\\PaymentController' => __DIR__ . '/../..' . '/app/Http/Controllers/PaymentController.php',
'App\\Http\\Controllers\\RegistrationController' => __DIR__ . '/../..' . '/app/Http/Controllers/RegistrationController.php',
'App\\Http\\Controllers\\RoundmailController' => __DIR__ . '/../..' . '/app/Http/Controllers/RoundmailController.php',
@ -318,6 +320,8 @@ class ComposerStaticInita19fb0695e1b61b4feeb3cc3fbdd2feb
'App\\Setting' => __DIR__ . '/../..' . '/app/Setting.php',
'App\\Tipp' => __DIR__ . '/../..' . '/app/Tipp.php',
'App\\User' => __DIR__ . '/../..' . '/app/User.php',
'App\\leagues\\League' => __DIR__ . '/../..' . '/app/leagues/League.php',
'App\\leagues\\Match' => __DIR__ . '/../..' . '/app/leagues/Match.php',
'Carbon\\Carbon' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/Carbon.php',
'Carbon\\CarbonInterval' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/CarbonInterval.php',
'Carbon\\Exceptions\\InvalidDateException' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/Exceptions/InvalidDateException.php',
@ -329,6 +333,8 @@ class ComposerStaticInita19fb0695e1b61b4feeb3cc3fbdd2feb
'Collective\\Html\\HtmlFacade' => __DIR__ . '/..' . '/laravelcollective/html/src/HtmlFacade.php',
'Collective\\Html\\HtmlServiceProvider' => __DIR__ . '/..' . '/laravelcollective/html/src/HtmlServiceProvider.php',
'CreateGamesTable' => __DIR__ . '/../..' . '/database/migrations/2017_06_19_112641_create_games_table.php',
'CreateLeaguesTable' => __DIR__ . '/../..' . '/database/migrations/2017_09_08_095721_create_leagues_table.php',
'CreateMatchesTable' => __DIR__ . '/../..' . '/database/migrations/2017_09_08_095740_create_matches_table.php',
'CreatePasswordResetsTable' => __DIR__ . '/../..' . '/database/migrations/2014_10_12_100000_create_password_resets_table.php',
'CreatePaymentsTable' => __DIR__ . '/../..' . '/database/migrations/2017_06_19_112638_create_payments_table.php',
'CreateQuotasTable' => __DIR__ . '/../..' . '/database/migrations/2017_08_16_164654_create_quotas_table.php',