X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=app%2FModels%2FChannel.php;h=edc2ba8664be682bc3638fbb16e485b905ca55a1;hb=0b25d0e8a22a13f09efbeab94d0b353ae603bc16;hp=738312dc3e82a60d6725a0289f2886a11b3dcc2e;hpb=93f50820771a0333b169f76f74727239cf0cb286;p=alttp.git diff --git a/app/Models/Channel.php b/app/Models/Channel.php index 738312d..edc2ba8 100644 --- a/app/Models/Channel.php +++ b/app/Models/Channel.php @@ -16,6 +16,10 @@ class Channel extends Model ->first(); } + public function getGuessingLeaderboard() { + return $this->winners()->selectRaw('(select t2.uname from guessing_winners t2 where t2.uid = guessing_winners.uid order by created_at desc limit 1) as name, sum(score) as score')->groupBy('uid')->orderBy('score', 'desc')->limit(10)->get(); + } + public function hasActiveGuessing() { return !is_null($this->guessing_start); } @@ -149,6 +153,10 @@ class Channel extends Model return $this->belongsTo(Organization::class); } + public function winners() { + return $this->hasMany(GuessingWinner::class); + } + protected $casts = [ 'chat' => 'boolean', 'chat_commands' => 'array',