X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FProtocol.php;h=995f9c02ab8707f33825d88147ba0191efa54cad;hb=a4260a00251cef4ad806c9d5c44d4c444d6ab831;hp=4659665e87ffddeed7adcae097afcd0df81f3cd2;hpb=d3c484627e5923d4843420ba06dc33c79101e891;p=alttp.git diff --git a/app/Models/Protocol.php b/app/Models/Protocol.php index 4659665..995f9c0 100644 --- a/app/Models/Protocol.php +++ b/app/Models/Protocol.php @@ -10,6 +10,20 @@ class Protocol extends Model { use HasFactory; + public static function resultCommented(Tournament $tournament, Result $result, User $user) { + $protocol = static::create([ + 'tournament_id' => $tournament->id, + 'user_id' => $user->id, + 'type' => 'result.comment', + 'details' => [ + 'tournament' => static::tournamentMemo($tournament), + 'result' => static::resultMemo($result), + 'round' => static::roundMemo($result->round), + ], + ]); + ProtocolAdded::dispatch($protocol); + } + public static function resultReported(Tournament $tournament, Result $result, User $user) { $protocol = static::create([ 'tournament_id' => $tournament->id, @@ -18,6 +32,7 @@ class Protocol extends Model 'details' => [ 'tournament' => static::tournamentMemo($tournament), 'result' => static::resultMemo($result), + 'round' => static::roundMemo($result->round), ], ]); ProtocolAdded::dispatch($protocol); @@ -103,6 +118,7 @@ class Protocol extends Model protected static function resultMemo(Result $result) { return [ 'id' => $result->id, + 'comment' => $result->comment, 'forfeit' => $result->forfeit, 'time' => $result->time, ]; @@ -111,6 +127,8 @@ class Protocol extends Model protected static function roundMemo(Round $round) { return [ 'id' => $round->id, + 'locked' => $round->locked, + 'no_record' => $round->no_record, 'number' => $round->number, 'seed' => $round->seed, ]; @@ -119,6 +137,8 @@ class Protocol extends Model protected static function tournamentMemo(Tournament $tournament) { return [ 'id' => $tournament->id, + 'locked' => $tournament->locked, + 'no_record' => $tournament->no_record, 'title' => $tournament->title, ]; }