mirror of
https://github.com/koel/koel
synced 2024-12-20 01:23:16 +00:00
17 lines
455 B
PHP
17 lines
455 B
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
use Illuminate\Support\Collection;
|
|
use Illuminate\Support\ServiceProvider;
|
|
|
|
class MacroProvider extends ServiceProvider
|
|
{
|
|
public function boot(): void
|
|
{
|
|
Collection::macro('orderByArray', function (array $orderBy, string $key = 'id'): Collection {
|
|
/** @var Collection $this */
|
|
return $this->sortBy(static fn ($item) => array_search($item->$key, $orderBy, true));
|
|
});
|
|
}
|
|
}
|