Skip to main content

koel/koel

16892 stars
1 code files
View koel/koel on GitHub

app/Services/SmartPlaylistService.php

Open in GitHub
use Illuminate\Database\Eloquent\Builder;
 
class SmartPlaylistService
{
//
public function buildQueryFromRules(array $rules): Builder
{
$query = Song::query();
 
collect($rules)->each(static function (array $ruleGroup) use ($query): void {
$query->orWhere(static function (Builder $subQuery) use ($ruleGroup): void {
foreach ($ruleGroup['rules'] as $config) {
Rule::create($config)->build($subQuery);
}
});
});
 
return $query;
}
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.