feat(search): add Playlist as searchable

This commit is contained in:
Phan An 2021-01-05 17:52:16 +01:00
parent 1b3445ceb6
commit d189c719ae
2 changed files with 13 additions and 0 deletions

View file

@ -4,6 +4,7 @@ namespace App\Console\Commands;
use App\Models\Album;
use App\Models\Artist;
use App\Models\Playlist;
use App\Models\Song;
use Illuminate\Console\Command;
@ -13,6 +14,7 @@ class ImportSearchableEntitiesCommand extends Command
Song::class,
Album::class,
Artist::class,
Playlist::class,
];
protected $signature = 'koel:search:import';

View file

@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Laravel\Scout\Searchable;
/**
* @property int $user_id
@ -23,6 +24,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
*/
class Playlist extends Model
{
use Searchable;
use CanFilterByUser;
use HasFactory;
@ -48,4 +50,13 @@ class Playlist extends Model
{
return (bool) $this->rules;
}
/** @return array<mixed> */
public function toSearchableArray(): array
{
return [
'id' => $this->id,
'name' => $this->name,
];
}
}