mirror of
https://github.com/koel/koel
synced 2024-11-14 00:17:13 +00:00
feat(search): add Playlist as searchable
This commit is contained in:
parent
1b3445ceb6
commit
d189c719ae
2 changed files with 13 additions and 0 deletions
|
@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\Album;
|
use App\Models\Album;
|
||||||
use App\Models\Artist;
|
use App\Models\Artist;
|
||||||
|
use App\Models\Playlist;
|
||||||
use App\Models\Song;
|
use App\Models\Song;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ class ImportSearchableEntitiesCommand extends Command
|
||||||
Song::class,
|
Song::class,
|
||||||
Album::class,
|
Album::class,
|
||||||
Artist::class,
|
Artist::class,
|
||||||
|
Playlist::class,
|
||||||
];
|
];
|
||||||
|
|
||||||
protected $signature = 'koel:search:import';
|
protected $signature = 'koel:search:import';
|
||||||
|
|
|
@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
|
use Laravel\Scout\Searchable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @property int $user_id
|
* @property int $user_id
|
||||||
|
@ -23,6 +24,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
*/
|
*/
|
||||||
class Playlist extends Model
|
class Playlist extends Model
|
||||||
{
|
{
|
||||||
|
use Searchable;
|
||||||
use CanFilterByUser;
|
use CanFilterByUser;
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
|
@ -48,4 +50,13 @@ class Playlist extends Model
|
||||||
{
|
{
|
||||||
return (bool) $this->rules;
|
return (bool) $this->rules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return array<mixed> */
|
||||||
|
public function toSearchableArray(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue