From: Daniel Karbach Date: Sat, 29 Nov 2025 11:10:36 +0000 (+0100) Subject: track result changes X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=5f3cca1bead2c8462b41d71bc97a5e95e0cd55cb;p=alttp.git track result changes --- diff --git a/app/Http/Controllers/ResultController.php b/app/Http/Controllers/ResultController.php index 14f92de..563fdd6 100644 --- a/app/Http/Controllers/ResultController.php +++ b/app/Http/Controllers/ResultController.php @@ -30,13 +30,16 @@ class ResultController extends Controller $this->authorize('create', Result::class); } - $result = Result::firstOrCreate([ + $result = Result::firstOrNew([ 'round_id' => $validatedData['round_id'], 'user_id' => $validatedData['user_id'], ]); if (!$round->locked && !$result->verified_at) { if (isset($validatedData['forfeit'])) $result->forfeit = $validatedData['forfeit']; if (isset($validatedData['time'])) $result->time = $validatedData['time']; + if ($result->id && $result->isDirty(['forfeit', 'time'])) { + ++$result->changed; + } } $result->comment = !empty($validatedData['comment']) ? $validatedData['comment'] : null; if (!$result->verified_at) { diff --git a/database/migrations/2025_11_29_105122_result_change_tracking.php b/database/migrations/2025_11_29_105122_result_change_tracking.php new file mode 100644 index 0000000..444e934 --- /dev/null +++ b/database/migrations/2025_11_29_105122_result_change_tracking.php @@ -0,0 +1,28 @@ +unsignedInteger('changed')->default(0); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('results', function (Blueprint $table) { + $table->dropColumn('changed'); + }); + } +};