X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FProtocol.php;h=4659665e87ffddeed7adcae097afcd0df81f3cd2;hb=d611bc90eab94fbce54e9e5485f15c20abf1ad31;hp=8adc5456474352562c4cbbb36503dacc2cf8e5ca;hpb=a907ef7c6676fef11f42933b2d79bdd496b20122;p=alttp.git diff --git a/app/Models/Protocol.php b/app/Models/Protocol.php index 8adc545..4659665 100644 --- a/app/Models/Protocol.php +++ b/app/Models/Protocol.php @@ -36,6 +36,19 @@ class Protocol extends Model ProtocolAdded::dispatch($protocol); } + public static function roundLocked(Tournament $tournament, Round $round, User $user = null) { + $protocol = static::create([ + 'tournament_id' => $tournament->id, + 'user_id' => $user ? $user->id : null, + 'type' => 'round.lock', + 'details' => [ + 'tournament' => static::tournamentMemo($tournament), + 'round' => static::roundMemo($round), + ], + ]); + ProtocolAdded::dispatch($protocol); + } + public static function roundSeedSet(Tournament $tournament, Round $round, User $user) { $protocol = static::create([ 'tournament_id' => $tournament->id, @@ -49,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, @@ -61,10 +87,23 @@ 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 [ 'id' => $result->id, + 'forfeit' => $result->forfeit, 'time' => $result->time, ]; } @@ -72,6 +111,7 @@ class Protocol extends Model protected static function roundMemo(Round $round) { return [ 'id' => $round->id, + 'number' => $round->number, 'seed' => $round->seed, ]; }