$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) {
--- /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::table('results', function (Blueprint $table) {
+ $table->unsignedInteger('changed')->default(0);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('results', function (Blueprint $table) {
+ $table->dropColumn('changed');
+ });
+ }
+};