diff options
author | Fbenas <philbeansburton@gmail.com> | 2020-06-19 02:16:51 +0100 |
---|---|---|
committer | Fbenas <philbeansburton@gmail.com> | 2020-06-19 02:16:51 +0100 |
commit | d1fe4536cc039450b540104e382db0d01d5cf886 (patch) | |
tree | fd40ab48f79370541f377b59bb381811126485ad /database | |
parent | c83e876693bdb71c66418c13f5e09dfdaef24478 (diff) |
Initial commit
Diffstat (limited to 'database')
-rw-r--r-- | database/migrations/2020_06_18_155337_create_match_team_table.php | 36 | ||||
-rw-r--r-- | database/migrations/2020_06_18_155337_create_match_tournament_table.php | 35 | ||||
-rw-r--r-- | database/migrations/2020_06_18_155337_create_matches_table.php | 38 | ||||
-rw-r--r-- | database/migrations/2020_06_18_155355_create_teams_table.php | 34 | ||||
-rw-r--r-- | database/migrations/2020_06_18_155355_create_tournaments_table.php | 34 | ||||
-rw-r--r-- | database/migrations/2020_06_18_155412_create_venues_table.php | 35 | ||||
-rw-r--r-- | database/seeds/DatabaseSeeder.php | 5 | ||||
-rw-r--r-- | database/seeds/MatchSeeder.php | 58 | ||||
-rw-r--r-- | database/seeds/TeamSeeder.php | 51 | ||||
-rw-r--r-- | database/seeds/TournamentSeeder.php | 21 | ||||
-rw-r--r-- | database/seeds/VenueSeeder.php | 51 |
11 files changed, 397 insertions, 1 deletions
diff --git a/database/migrations/2020_06_18_155337_create_match_team_table.php b/database/migrations/2020_06_18_155337_create_match_team_table.php new file mode 100644 index 0000000..a1e7d0e --- /dev/null +++ b/database/migrations/2020_06_18_155337_create_match_team_table.php @@ -0,0 +1,36 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateMatchTeamTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create( + 'match_team', function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('match_id'); + $table->unsignedInteger('team_id'); + $table->boolean('is_home'); + $table->timestamps(); + } + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('match_team'); + } +} diff --git a/database/migrations/2020_06_18_155337_create_match_tournament_table.php b/database/migrations/2020_06_18_155337_create_match_tournament_table.php new file mode 100644 index 0000000..02f0e91 --- /dev/null +++ b/database/migrations/2020_06_18_155337_create_match_tournament_table.php @@ -0,0 +1,35 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateMatchTournamentTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create( + 'match_tournament', function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('match_id'); + $table->unsignedInteger('tournament_id'); + $table->timestamps(); + } + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('match_tournament'); + } +} diff --git a/database/migrations/2020_06_18_155337_create_matches_table.php b/database/migrations/2020_06_18_155337_create_matches_table.php new file mode 100644 index 0000000..a443371 --- /dev/null +++ b/database/migrations/2020_06_18_155337_create_matches_table.php @@ -0,0 +1,38 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateMatchesTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create( + 'matches', function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('venue_id')->nullable(); + $table->string('referee')->nullable(); + $table->string('score')->nullable(); + $table->string('half_score')->nullable(); + $table->dateTime('date')->nullable(); + $table->timestamps(); + } + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('matches'); + } +} diff --git a/database/migrations/2020_06_18_155355_create_teams_table.php b/database/migrations/2020_06_18_155355_create_teams_table.php new file mode 100644 index 0000000..3e0d58f --- /dev/null +++ b/database/migrations/2020_06_18_155355_create_teams_table.php @@ -0,0 +1,34 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateTeamsTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create( + 'teams', function (Blueprint $table) { + $table->id(); + $table->string('name'); + $table->timestamps(); + } + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('teams'); + } +} diff --git a/database/migrations/2020_06_18_155355_create_tournaments_table.php b/database/migrations/2020_06_18_155355_create_tournaments_table.php new file mode 100644 index 0000000..8dc267a --- /dev/null +++ b/database/migrations/2020_06_18_155355_create_tournaments_table.php @@ -0,0 +1,34 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateTournamentsTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create( + 'tournaments', function (Blueprint $table) { + $table->id(); + $table->string('name'); + $table->timestamps(); + } + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('tournaments'); + } +} diff --git a/database/migrations/2020_06_18_155412_create_venues_table.php b/database/migrations/2020_06_18_155412_create_venues_table.php new file mode 100644 index 0000000..e2c84b2 --- /dev/null +++ b/database/migrations/2020_06_18_155412_create_venues_table.php @@ -0,0 +1,35 @@ +<?php + +use Illuminate\Database\Migrations\Migration; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Support\Facades\Schema; + +class CreateVenuesTable extends Migration +{ + /** + * Run the migrations. + * + * @return void + */ + public function up() + { + Schema::create( + 'venues', function (Blueprint $table) { + $table->id(); + $table->string('name'); + $table->string('city')->nullable(); + $table->timestamps(); + } + ); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('venues'); + } +} diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 237dfc5..21ec948 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -11,6 +11,9 @@ class DatabaseSeeder extends Seeder */ public function run() { - // $this->call(UserSeeder::class); + $this->call(VenueSeeder::class); + $this->call(TeamSeeder::class); + $this->call(TournamentSeeder::class); + $this->call(MatchSeeder::class); } } diff --git a/database/seeds/MatchSeeder.php b/database/seeds/MatchSeeder.php new file mode 100644 index 0000000..f0d95f6 --- /dev/null +++ b/database/seeds/MatchSeeder.php @@ -0,0 +1,58 @@ +<?php + +use Illuminate\Database\Seeder; +use App\Rugby\Model; + +class MatchSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + $match1 = Model\Match::create( + [ + 'venue_id' => 1, + ] + ); + + $match1->teams()->sync( + [ + 1 => ['is_home' => true], + 4 => ['is_home' => false] + ] + ); + + $match2 = Model\Match::create( + [ + 'venue_id' => 2, + ] + ); + + $match2->teams()->sync( + [ + 2 => ['is_home' => true], + 5 => ['is_home' => false] + ] + ); + + $match3 = Model\Match::create( + [ + 'venue_id' => 3, + ] + ); + + $match3->teams()->sync( + [ + 3 => ['is_home' => true], + 6 => ['is_home' => false] + ] + ); + + $match1->tournaments()->sync(1); + $match2->tournaments()->sync(1); + $match3->tournaments()->sync(1); + } +} diff --git a/database/seeds/TeamSeeder.php b/database/seeds/TeamSeeder.php new file mode 100644 index 0000000..250ce94 --- /dev/null +++ b/database/seeds/TeamSeeder.php @@ -0,0 +1,51 @@ +<?php + +use Illuminate\Database\Seeder; +use App\Rugby\Model; + +class TeamSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + Model\Team::create( + [ + 'name' => 'England' + ] + ); + + Model\Team::create( + [ + 'name' => 'France' + ] + ); + + Model\Team::create( + [ + 'name' => 'Italy' + ] + ); + + Model\Team::create( + [ + 'name' => 'Wales' + ] + ); + + Model\Team::create( + [ + 'name' => 'Scotland' + ] + ); + + Model\Team::create( + [ + 'name' => 'Ireland' + ] + ); + } +} diff --git a/database/seeds/TournamentSeeder.php b/database/seeds/TournamentSeeder.php new file mode 100644 index 0000000..070e0fb --- /dev/null +++ b/database/seeds/TournamentSeeder.php @@ -0,0 +1,21 @@ +<?php + +use Illuminate\Database\Seeder; +use App\Rugby; + +class TournamentSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + Rugby\Tournament::create( + [ + 'name' => 'RBS Six Nations' + ] + ); + } +} diff --git a/database/seeds/VenueSeeder.php b/database/seeds/VenueSeeder.php new file mode 100644 index 0000000..f95e4ef --- /dev/null +++ b/database/seeds/VenueSeeder.php @@ -0,0 +1,51 @@ +<?php + +use Illuminate\Database\Seeder; +use App\Rugby\Model; + +class VenueSeeder extends Seeder +{ + /** + * Run the database seeds. + * + * @return void + */ + public function run() + { + Model\Venue::create( + [ + 'name' => 'Twickenham' + ] + ); + + Model\Venue::create( + [ + 'name' => 'Stade de France' + ] + ); + + Model\Venue::create( + [ + 'name' => 'Stadio Olimpico' + ] + ); + + Model\Venue::create( + [ + 'name' => 'Millennium Stadium' + ] + ); + + Model\Venue::create( + [ + 'name' => 'Murrayfield Stadium' + ] + ); + + Model\Venue::create( + [ + 'name' => 'Aviva Stadium' + ] + ); + } +} |