use App\Events\ApplicationAdded;
use App\Events\TournamentChanged;
use App\Models\Application;
+use App\Models\GroupAssignment;
use App\Models\Protocol;
use App\Models\Tournament;
use Illuminate\Auth\Access\AuthorizationException;
}
$json = $tournament->toArray();
$json['rounds'] = $rounds->toArray();
+ if ($request->user()) {
+ $json['group_assignments'] = GroupAssignment::query()
+ ->whereBelongsTo($tournament)
+ ->whereBelongsTo($request->user())
+ ->get()
+ ->toArray();
+ }
return $json;
}
--- /dev/null
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class GroupAssignment extends Model {
+
+ public function tournament() {
+ return $this->belongsTo(Tournament::class);
+ }
+
+ public function user() {
+ return $this->belongsTo(User::class);
+ }
+
+}
--- /dev/null
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+
+ /**
+ * Run the migrations.
+ */
+ public function up(): void
+ {
+ Schema::create('group_assignments', function (Blueprint $table) {
+ $table->id();
+ $table->foreignId('tournament_id')->constrained();
+ $table->foreignId('user_id')->constrained();
+ $table->integer('round_number');
+ $table->string('group');
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('group_assignments');
+ }
+
+};