X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FProtocol.php;h=4659665e87ffddeed7adcae097afcd0df81f3cd2;hb=d1f28ea443b090c7593791eba9631796ccaeafe1;hp=fee8b881b492b0e0739df1289d3cde53c7575a19;hpb=09c1644b5f64d7423905ae1be8f79da0b482289a;p=alttp.git diff --git a/app/Models/Protocol.php b/app/Models/Protocol.php index fee8b88..4659665 100644 --- a/app/Models/Protocol.php +++ b/app/Models/Protocol.php @@ -62,6 +62,19 @@ class Protocol extends Model ProtocolAdded::dispatch($protocol); } + public static function roundUnlocked(Tournament $tournament, Round $round, User $user = null) { + $protocol = static::create([ + 'tournament_id' => $tournament->id, + 'user_id' => $user ? $user->id : null, + 'type' => 'round.unlock', + 'details' => [ + 'tournament' => static::tournamentMemo($tournament), + 'round' => static::roundMemo($round), + ], + ]); + ProtocolAdded::dispatch($protocol); + } + public static function tournamentCreated(Tournament $tournament, User $user) { $protocol = static::create([ 'tournament_id' => $tournament->id, @@ -74,6 +87,18 @@ class Protocol extends Model ProtocolAdded::dispatch($protocol); } + public static function tournamentLocked(Tournament $tournament, User $user = null) { + $protocol = static::create([ + 'tournament_id' => $tournament->id, + 'user_id' => $user ? $user->id : null, + 'type' => 'tournament.lock', + 'details' => [ + 'tournament' => static::tournamentMemo($tournament), + ], + ]); + ProtocolAdded::dispatch($protocol); + } + protected static function resultMemo(Result $result) { return [ @@ -86,6 +111,7 @@ class Protocol extends Model protected static function roundMemo(Round $round) { return [ 'id' => $round->id, + 'number' => $round->number, 'seed' => $round->seed, ]; }