--- /dev/null
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\Result;
+use Illuminate\Console\Command;
+
+class RecalculateResultChanges extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'result:recalc-changes';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = 'Command description';
+
+ /**
+ * Execute the console command.
+ */
+ public function handle()
+ {
+ $results = Result::all();
+ foreach ($results as $result) {
+ $reports = $result->round->protocols()
+ ->where('type', '=', 'result.report')
+ ->where('user_id', '=', $result->user_id)
+ ->count();
+ if ($reports > 1) {
+ $result->changed = $reports - 1;
+ $result->save();
+ }
+ }
+ }
+}