'id' => 'array',
'id.*' => 'integer|numeric',
'joinable' => 'boolean|nullable',
+ 'limit' => 'numeric|nullable',
'manageable' => 'boolean|nullable',
'phrase' => 'string|nullable',
]);
+ $limit = isset($validatedData['limit']) ? $validatedData['limit'] : 100;
+
$channels = Channel::query();
if (!empty($validatedData['id'])) {
$channels = $channels->whereIn('id', $validatedData['id']);
$channels = $channels->where('title', 'LIKE', '%'.$validatedData['phrase'].'%')
->orWhere('short_name', 'LIKE', '%'.$validatedData['phrase'].'%');
}
- $channels = $channels->limit(5);
+ $channels
+ ->orderBy('twitch_live', 'DESC')
+ ->orderBy('twitch_viewers', 'DESC')
+ ->orderBy('title', 'ASC')
+ ->limit($limit);
return $this->sendChannels($channels->get());
}