]> git.localhorst.tv Git - alttp.git/commitdiff
add model dummies
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 9 Mar 2022 17:33:54 +0000 (18:33 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Wed, 9 Mar 2022 17:33:54 +0000 (18:33 +0100)
22 files changed:
app/Http/Controllers/ParticipantController.php [new file with mode: 0644]
app/Http/Controllers/ProtocolController.php [new file with mode: 0644]
app/Http/Controllers/ResultController.php [new file with mode: 0644]
app/Http/Controllers/RoundController.php [new file with mode: 0644]
app/Http/Controllers/TournamentController.php [new file with mode: 0644]
app/Models/Participant.php [new file with mode: 0644]
app/Models/Protocol.php [new file with mode: 0644]
app/Models/Result.php [new file with mode: 0644]
app/Models/Round.php [new file with mode: 0644]
app/Models/Tournament.php [new file with mode: 0644]
app/Models/User.php
app/Policies/ParticipantPolicy.php [new file with mode: 0644]
app/Policies/ProtocolPolicy.php [new file with mode: 0644]
app/Policies/ResultPolicy.php [new file with mode: 0644]
app/Policies/RoundPolicy.php [new file with mode: 0644]
app/Policies/TournamentPolicy.php [new file with mode: 0644]
database/migrations/2022_03_09_163037_add_user_role.php [new file with mode: 0644]
database/migrations/2022_03_09_165525_create_tournaments_table.php [new file with mode: 0644]
database/migrations/2022_03_09_165535_create_participants_table.php [new file with mode: 0644]
database/migrations/2022_03_09_165540_create_rounds_table.php [new file with mode: 0644]
database/migrations/2022_03_09_165556_create_results_table.php [new file with mode: 0644]
database/migrations/2022_03_09_170353_create_protocols_table.php [new file with mode: 0644]

diff --git a/app/Http/Controllers/ParticipantController.php b/app/Http/Controllers/ParticipantController.php
new file mode 100644 (file)
index 0000000..13d7efb
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class ParticipantController extends Controller
+{
+       //
+}
diff --git a/app/Http/Controllers/ProtocolController.php b/app/Http/Controllers/ProtocolController.php
new file mode 100644 (file)
index 0000000..c7e3bd2
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class ProtocolController extends Controller
+{
+       //
+}
diff --git a/app/Http/Controllers/ResultController.php b/app/Http/Controllers/ResultController.php
new file mode 100644 (file)
index 0000000..d31d444
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class ResultController extends Controller
+{
+       //
+}
diff --git a/app/Http/Controllers/RoundController.php b/app/Http/Controllers/RoundController.php
new file mode 100644 (file)
index 0000000..a6754ed
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class RoundController extends Controller
+{
+       //
+}
diff --git a/app/Http/Controllers/TournamentController.php b/app/Http/Controllers/TournamentController.php
new file mode 100644 (file)
index 0000000..edf6d12
--- /dev/null
@@ -0,0 +1,10 @@
+<?php
+
+namespace App\Http\Controllers;
+
+use Illuminate\Http\Request;
+
+class TournamentController extends Controller
+{
+       //
+}
diff --git a/app/Models/Participant.php b/app/Models/Participant.php
new file mode 100644 (file)
index 0000000..36ab3cf
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Participant extends Model
+{
+       use HasFactory;
+
+       public function tournament() {
+               return $this->belongsTo(Tournament::class);
+       }
+
+       public function user() {
+               return $this->belongsTo(User::class);
+       }
+
+}
diff --git a/app/Models/Protocol.php b/app/Models/Protocol.php
new file mode 100644 (file)
index 0000000..fb93a37
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Protocol extends Model
+{
+       use HasFactory;
+
+       public function tournament() {
+               return $this->belongsTo(Tournament::class);
+       }
+
+       public function user() {
+               return $this->belongsTo(User::class);
+       }
+
+}
diff --git a/app/Models/Result.php b/app/Models/Result.php
new file mode 100644 (file)
index 0000000..e693fc7
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Result extends Model
+{
+       use HasFactory;
+
+       public function round() {
+               return $this->belongsTo(Round::class);
+       }
+
+       public function participant() {
+               return $this->belongsTo(Participant::class);
+       }
+
+}
diff --git a/app/Models/Round.php b/app/Models/Round.php
new file mode 100644 (file)
index 0000000..9420692
--- /dev/null
@@ -0,0 +1,20 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Round extends Model
+{
+       use HasFactory;
+
+       public function results() {
+               return $this->hasMany(Result::class);
+       }
+
+       public function tournament() {
+               return $this->belongsTo(Tournament::class);
+       }
+
+}
diff --git a/app/Models/Tournament.php b/app/Models/Tournament.php
new file mode 100644 (file)
index 0000000..a19e179
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class Tournament extends Model
+{
+       use HasFactory;
+
+       public function participants() {
+               return $this->hasMany(Participant::class);
+       }
+
+       public function protocols() {
+               return $this->hasMany(Protocol::class);
+       }
+
+       public function rounds() {
+               return $this->hasMany(Round::class);
+       }
+
+}
index 7f216edbbe8addd8a0600ee43e6921b6a40310e7..dd129821890d28e9736b81bd6aaa800f35d15333 100644 (file)
@@ -10,49 +10,50 @@ use Laravel\Sanctum\HasApiTokens;
 
 class User extends Authenticatable
 {
-    use HasApiTokens, HasFactory, Notifiable;
+       use HasApiTokens, HasFactory, Notifiable;
 
-    /**
-     * The attributes that are mass assignable.
-     *
-     * @var string[]
-     */
-    protected $fillable = [
-        'id',
-        'username',
-        'discriminator',
-        'email',
-        'avatar',
-        'verified',
-        'locale',
-        'mfa_enabled',
-        'refresh_token'
-    ];
+       /**
+        * The attributes that are mass assignable.
+        *
+        * @var string[]
+        */
+       protected $fillable = [
+               'id',
+               'username',
+               'discriminator',
+               'email',
+               'avatar',
+               'verified',
+               'locale',
+               'mfa_enabled',
+               'refresh_token',
+               'role',
+       ];
 
-    /**
-     * The attributes that should be hidden for serialization.
-     *
-     * @var array
-     */
-    protected $hidden = [
-        'refresh_token',
-        'remember_token',
-    ];
+       /**
+        * The attributes that should be hidden for serialization.
+        *
+        * @var array
+        */
+       protected $hidden = [
+               'refresh_token',
+               'remember_token',
+       ];
 
-    /**
-     * The attributes that should be cast.
-     *
-     * @var array
-     */
-    protected $casts = [
-        'id' => 'string',
-        'username' => 'string',
-        'discriminator' => 'string',
-        'email' => 'string',
-        'avatar' => 'string',
-        'verified' => 'boolean',
-        'locale' => 'string',
-        'mfa_enabled' => 'boolean',
-        'refresh_token' => 'encrypted',
-    ];
+       /**
+        * The attributes that should be cast.
+        *
+        * @var array
+        */
+       protected $casts = [
+               'id' => 'string',
+               'username' => 'string',
+               'discriminator' => 'string',
+               'email' => 'string',
+               'avatar' => 'string',
+               'verified' => 'boolean',
+               'locale' => 'string',
+               'mfa_enabled' => 'boolean',
+               'refresh_token' => 'encrypted',
+       ];
 }
diff --git a/app/Policies/ParticipantPolicy.php b/app/Policies/ParticipantPolicy.php
new file mode 100644 (file)
index 0000000..f5b5246
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Policies;
+
+use App\Models\Participant;
+use App\Models\User;
+use Illuminate\Auth\Access\HandlesAuthorization;
+
+class ParticipantPolicy
+{
+       use HandlesAuthorization;
+
+       /**
+        * Determine whether the user can view any models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function viewAny(User $user)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can view the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Participant  $participant
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function view(User $user, Participant $participant)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can create models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function create(User $user)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can update the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Participant  $participant
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function update(User $user, Participant $participant)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Participant  $participant
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function delete(User $user, Participant $participant)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can restore the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Participant  $participant
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function restore(User $user, Participant $participant)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can permanently delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Participant  $participant
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function forceDelete(User $user, Participant $participant)
+       {
+               return false;
+       }
+}
diff --git a/app/Policies/ProtocolPolicy.php b/app/Policies/ProtocolPolicy.php
new file mode 100644 (file)
index 0000000..186fe09
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Policies;
+
+use App\Models\Protocol;
+use App\Models\User;
+use Illuminate\Auth\Access\HandlesAuthorization;
+
+class ProtocolPolicy
+{
+       use HandlesAuthorization;
+
+       /**
+        * Determine whether the user can view any models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function viewAny(User $user)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can view the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Protocol  $protocol
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function view(User $user, Protocol $protocol)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can create models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function create(User $user)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can update the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Protocol  $protocol
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function update(User $user, Protocol $protocol)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Protocol  $protocol
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function delete(User $user, Protocol $protocol)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can restore the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Protocol  $protocol
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function restore(User $user, Protocol $protocol)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can permanently delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Protocol  $protocol
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function forceDelete(User $user, Protocol $protocol)
+       {
+               return false;
+       }
+}
diff --git a/app/Policies/ResultPolicy.php b/app/Policies/ResultPolicy.php
new file mode 100644 (file)
index 0000000..7419431
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Policies;
+
+use App\Models\Result;
+use App\Models\User;
+use Illuminate\Auth\Access\HandlesAuthorization;
+
+class ResultPolicy
+{
+       use HandlesAuthorization;
+
+       /**
+        * Determine whether the user can view any models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function viewAny(User $user)
+       {
+               return true;
+       }
+
+       /**
+        * Determine whether the user can view the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Result  $result
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function view(User $user, Result $result)
+       {
+               return true;
+       }
+
+       /**
+        * Determine whether the user can create models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function create(User $user)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can update the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Result  $result
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function update(User $user, Result $result)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Result  $result
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function delete(User $user, Result $result)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can restore the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Result  $result
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function restore(User $user, Result $result)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can permanently delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Result  $result
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function forceDelete(User $user, Result $result)
+       {
+               return false;
+       }
+}
diff --git a/app/Policies/RoundPolicy.php b/app/Policies/RoundPolicy.php
new file mode 100644 (file)
index 0000000..045785d
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Policies;
+
+use App\Models\Round;
+use App\Models\User;
+use Illuminate\Auth\Access\HandlesAuthorization;
+
+class RoundPolicy
+{
+       use HandlesAuthorization;
+
+       /**
+        * Determine whether the user can view any models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function viewAny(User $user)
+       {
+               return true;
+       }
+
+       /**
+        * Determine whether the user can view the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Round  $round
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function view(User $user, Round $round)
+       {
+               return true;
+       }
+
+       /**
+        * Determine whether the user can create models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function create(User $user)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can update the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Round  $round
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function update(User $user, Round $round)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Round  $round
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function delete(User $user, Round $round)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can restore the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Round  $round
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function restore(User $user, Round $round)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can permanently delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Round  $round
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function forceDelete(User $user, Round $round)
+       {
+               return false;
+       }
+}
diff --git a/app/Policies/TournamentPolicy.php b/app/Policies/TournamentPolicy.php
new file mode 100644 (file)
index 0000000..b79f8c1
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+
+namespace App\Policies;
+
+use App\Models\Tournament;
+use App\Models\User;
+use Illuminate\Auth\Access\HandlesAuthorization;
+
+class TournamentPolicy
+{
+       use HandlesAuthorization;
+
+       /**
+        * Determine whether the user can view any models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function viewAny(User $user)
+       {
+               return true;
+       }
+
+       /**
+        * Determine whether the user can view the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Tournament  $tournament
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function view(User $user, Tournament $tournament)
+       {
+               return true;
+       }
+
+       /**
+        * Determine whether the user can create models.
+        *
+        * @param  \App\Models\User  $user
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function create(User $user)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can update the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Tournament  $tournament
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function update(User $user, Tournament $tournament)
+       {
+               return $user->role === 'admin';
+       }
+
+       /**
+        * Determine whether the user can delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Tournament  $tournament
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function delete(User $user, Tournament $tournament)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can restore the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Tournament  $tournament
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function restore(User $user, Tournament $tournament)
+       {
+               return false;
+       }
+
+       /**
+        * Determine whether the user can permanently delete the model.
+        *
+        * @param  \App\Models\User  $user
+        * @param  \App\Models\Tournament  $tournament
+        * @return \Illuminate\Auth\Access\Response|bool
+        */
+       public function forceDelete(User $user, Tournament $tournament)
+       {
+               return false;
+       }
+}
diff --git a/database/migrations/2022_03_09_163037_add_user_role.php b/database/migrations/2022_03_09_163037_add_user_role.php
new file mode 100644 (file)
index 0000000..cf4f428
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::table('users', function(Blueprint $table) {
+                       $table->string('role')->default('user');
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::table('users', function(Blueprint $table) {
+                       $table->dropColumn('role');
+               });
+       }
+};
diff --git a/database/migrations/2022_03_09_165525_create_tournaments_table.php b/database/migrations/2022_03_09_165525_create_tournaments_table.php
new file mode 100644 (file)
index 0000000..07fe283
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::create('tournaments', function (Blueprint $table) {
+                       $table->id();
+                       $table->string('title');
+                       $table->timestamps();
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::dropIfExists('tournaments');
+       }
+};
diff --git a/database/migrations/2022_03_09_165535_create_participants_table.php b/database/migrations/2022_03_09_165535_create_participants_table.php
new file mode 100644 (file)
index 0000000..fe7c212
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::create('participants', function (Blueprint $table) {
+                       $table->id();
+                       $table->foreignId('tournament_id')->constrained();
+                       $table->foreignId('user_id')->constrained();
+                       $table->timestamps();
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::dropIfExists('participants');
+       }
+};
diff --git a/database/migrations/2022_03_09_165540_create_rounds_table.php b/database/migrations/2022_03_09_165540_create_rounds_table.php
new file mode 100644 (file)
index 0000000..24b9dfe
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::create('rounds', function (Blueprint $table) {
+                       $table->id();
+                       $table->foreignId('tournament_id')->constrained();
+                       $table->string('seed');
+                       $table->timestamps();
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::dropIfExists('rounds');
+       }
+};
diff --git a/database/migrations/2022_03_09_165556_create_results_table.php b/database/migrations/2022_03_09_165556_create_results_table.php
new file mode 100644 (file)
index 0000000..b08b11b
--- /dev/null
@@ -0,0 +1,36 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::create('results', function (Blueprint $table) {
+                       $table->id();
+                       $table->foreignId('round_id')->constrained();
+                       $table->foreignId('user_id')->constrained();
+                       $table->double('time');
+                       $table->timestamps();
+
+                       $table->unique(['round_id', 'user_id']);
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::dropIfExists('results');
+       }
+};
diff --git a/database/migrations/2022_03_09_170353_create_protocols_table.php b/database/migrations/2022_03_09_170353_create_protocols_table.php
new file mode 100644 (file)
index 0000000..4c77058
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+       /**
+        * Run the migrations.
+        *
+        * @return void
+        */
+       public function up()
+       {
+               Schema::create('protocols', function (Blueprint $table) {
+                       $table->id();
+                       $table->foreignId('tournament_id')->constrained();
+                       $table->foreignId('user_id')->nullable()->constrained();
+                       $table->string('type');
+                       $table->text('details');
+                       $table->timestamps();
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::dropIfExists('protocols');
+       }
+};