X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FProtocol.php;h=e182c0885ae6e07e2f8bb12698b8c51adda64424;hb=d748feb96453d74aeffec648d6f5f68d9ef3b520;hp=bbfea732fe97fecfc5a7a48da553580577bc78bf;hpb=c30ac282dde3d746d6a7762ee18c70b4416500b5;p=alttp.git diff --git a/app/Models/Protocol.php b/app/Models/Protocol.php index bbfea73..e182c08 100644 --- a/app/Models/Protocol.php +++ b/app/Models/Protocol.php @@ -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,