X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FChannel.php;h=c6dfb6aaa19b57a019b51dba4f4167b49382e094;hb=4b8475936f9c0f0379d2dee4e1440f4445682715;hp=8045a4194fa529561ba6a091c0aa7770beb18dce;hpb=da5cc01782f2247feb08a3c2117dbe933ba7924f;p=alttp.git diff --git a/app/Models/Channel.php b/app/Models/Channel.php index 8045a41..c6dfb6a 100644 --- a/app/Models/Channel.php +++ b/app/Models/Channel.php @@ -43,14 +43,23 @@ class Channel extends Model { } public function queryChatlog() { - return ChatLog::where('type', '=', 'chat') + $min_age = $this->getChatSetting('min_age', 1); + $query = ChatLog::where('type', '=', 'chat') ->where('banned', '=', false) - ->where('created_at', '<', now()->sub(1, 'day')) + ->where('created_at', '<', now()->sub($min_age, 'day')) ->where(function ($query) { $query->whereNull('detected_language'); $query->orWhereIn('detected_language', $this->getPreferredLanguages()); }) ->inRandomOrder(); + $source = $this->getChatSetting('source', 'any'); + if (in_array($source, ['catchan', 'chan'])) { + $query->where('channel_id', $this->id); + } + if (in_array($source, ['cat', 'catchan'])) { + $query->where('twitch_category', $this->twitch_category); + } + return $query; } public function getPreferredLanguages() {