]> git.localhorst.tv Git - alttp.git/commitdiff
no_record rounds and tournaments
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 25 Mar 2022 11:08:14 +0000 (12:08 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Fri, 25 Mar 2022 11:08:14 +0000 (12:08 +0100)
app/Http/Controllers/RoundController.php
app/Models/Round.php
app/Models/User.php
database/migrations/2022_03_25_110011_no_record.php [new file with mode: 0644]

index 4938b3a04a0bac61c31ccd2d2ba49dd604d2209c..d616b861b3d0edb8c22d99679ae4f56614d1a079 100644 (file)
@@ -23,6 +23,7 @@ class RoundController extends Controller
 
                $round = Round::create([
                        'number' => intval($tournament->rounds_max_number) + 1,
+                       'no_record' => $tournament->no_record,
                        'tournament_id' => $validatedData['tournament_id'],
                ]);
 
index 3777df9e8e96040717fa8ce3e97e0d878188463c..2232a0e2c95d675411de55c045e7f677217394d0 100644 (file)
@@ -69,6 +69,7 @@ class Round extends Model
 
        protected $fillable = [
                'number',
+               'no_record',
                'tournament_id',
        ];
 
index b4950c306c458fc5973f2a899f7021f93603f53d..89493e70171cdec6eefeea22e70f4bc1c9f342dd 100644 (file)
@@ -59,37 +59,43 @@ class User extends Authenticatable
 
        public function round_first() {
                return $this->rounds()
-                       ->whereNot('locked')
+                       ->where('locked', true)
+                       ->where('no_record', false)
                        ->wherePivot('placement', 1);
        }
 
        public function round_second() {
                return $this->rounds()
-                       ->whereNot('locked')
+                       ->where('locked', true)
+                       ->where('no_record', false)
                        ->wherePivot('placement', 2);
        }
 
        public function round_third() {
                return $this->rounds()
-                       ->whereNot('locked')
+                       ->where('locked', true)
+                       ->where('no_record', false)
                        ->wherePivot('placement', 3);
        }
 
        public function tournament_first() {
                return $this->tournaments()
-                       ->whereNot('locked')
+                       ->where('locked', true)
+                       ->where('no_record', false)
                        ->wherePivot('placement', 1);
        }
 
        public function tournament_second() {
                return $this->tournaments()
-                       ->whereNot('locked')
+                       ->where('locked', true)
+                       ->where('no_record', false)
                        ->wherePivot('placement', 2);
        }
 
        public function tournament_third() {
                return $this->tournaments()
-                       ->whereNot('locked')
+                       ->where('locked', true)
+                       ->where('no_record', false)
                        ->wherePivot('placement', 3);
        }
 
diff --git a/database/migrations/2022_03_25_110011_no_record.php b/database/migrations/2022_03_25_110011_no_record.php
new file mode 100644 (file)
index 0000000..1874d7c
--- /dev/null
@@ -0,0 +1,38 @@
+<?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('rounds', function(Blueprint $table) {
+                       $table->boolean('no_record')->default(false);
+               });
+               Schema::table('tournaments', function(Blueprint $table) {
+                       $table->boolean('no_record')->default(false);
+               });
+       }
+
+       /**
+        * Reverse the migrations.
+        *
+        * @return void
+        */
+       public function down()
+       {
+               Schema::table('rounds', function(Blueprint $table) {
+                       $table->dropColumn('no_record');
+               });
+               Schema::table('tournaments', function(Blueprint $table) {
+                       $table->dropColumn('no_record');
+               });
+       }
+};