]> git.localhorst.tv Git - alttp.git/commitdiff
additional channel filters master
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 21 Nov 2024 16:16:09 +0000 (17:16 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 21 Nov 2024 16:16:09 +0000 (17:16 +0100)
app/Http/Controllers/ChannelController.php

index ae57e319e1a2d52bb19b2a6010bbbed5905fe1d1..4de8baa34ce6ca6bad6d04e5c070644f1b359cb6 100644 (file)
@@ -17,7 +17,9 @@ class ChannelController extends Controller {
                        'id' => 'array',
                        'id.*' => 'integer|numeric',
                        'joinable' => 'boolean|nullable',
+                       'joined' => 'boolean|nullable',
                        'limit' => 'numeric|nullable',
+                       'logging' => 'boolean|nullable',
                        'manageable' => 'boolean|nullable',
                        'phrase' => 'string|nullable',
                ]);
@@ -34,6 +36,18 @@ class ChannelController extends Controller {
                if (isset($validatedData['joinable']) && $validatedData['joinable']) {
                        $channels = $channels->where('twitch_chat', '!=', '');
                }
+               if (isset($validatedData['joined'])) {
+                       $channels = $channels->where('join', '=', !!$validatedData['joined']);
+               }
+               if (isset($validatedData['logging'])) {
+                       if (!!$validatedData['logging']) {
+                               $channels = $channels->where('chat', '=', true);
+                               $channels = $channels->orWhere('join', '=', true);
+                       } else {
+                               $channels = $channels->where('chat', '=', false);
+                               $channels = $channels->where('join', '=', false);
+                       }
+               }
                if (isset($validatedData['manageable']) && $validatedData['manageable']) {
                        $user = $request->user();
                        if (!$user) {