]> git.localhorst.tv Git - alttp.git/blobdiff - app/Models/Protocol.php
result reporting
[alttp.git] / app / Models / Protocol.php
index bbfea732fe97fecfc5a7a48da553580577bc78bf..e182c0885ae6e07e2f8bb12698b8c51adda64424 100644 (file)
@@ -10,6 +10,19 @@ class Protocol extends Model
 {
        use HasFactory;
 
+       public static function resultReported(Tournament $tournament, Result $result, User $user) {
+               $protocol = static::create([
+                       'tournament_id' => $tournament->id,
+                       'user_id' => $user->id,
+                       'type' => 'result.report',
+                       'details' => [
+                               'tournament' => static::tournamentMemo($tournament),
+                               'result' => static::resultMemo($result),
+                       ],
+               ]);
+               ProtocolAdded::dispatch($protocol);
+       }
+
        public static function roundAdded(Tournament $tournament, Round $round, User $user) {
                $protocol = static::create([
                        'tournament_id' => $tournament->id,
@@ -36,6 +49,13 @@ class Protocol extends Model
        }
 
 
+       protected static function resultMemo(Result $result) {
+               return [
+                       'id' => $result->id,
+                       'time' => $result->time,
+               ];
+       }
+
        protected static function roundMemo(Round $round) {
                return [
                        'id' => $round->id,