2020-12-23 10:53:17 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use App\Models\Album;
|
|
|
|
use App\Models\Artist;
|
2021-01-05 16:52:16 +00:00
|
|
|
use App\Models\Playlist;
|
2024-06-08 16:22:15 +00:00
|
|
|
use App\Models\Podcast;
|
2020-12-23 10:53:17 +00:00
|
|
|
use App\Models\Song;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
|
|
|
class ImportSearchableEntitiesCommand extends Command
|
|
|
|
{
|
|
|
|
private const SEARCHABLE_ENTITIES = [
|
|
|
|
Song::class,
|
|
|
|
Album::class,
|
|
|
|
Artist::class,
|
2021-01-05 16:52:16 +00:00
|
|
|
Playlist::class,
|
2024-06-08 16:22:15 +00:00
|
|
|
Podcast::class,
|
2020-12-23 10:53:17 +00:00
|
|
|
];
|
|
|
|
|
2020-12-23 13:04:02 +00:00
|
|
|
protected $signature = 'koel:search:import';
|
2020-12-23 10:53:17 +00:00
|
|
|
protected $description = 'Import all searchable entities with Scout';
|
|
|
|
|
|
|
|
public function handle(): int
|
|
|
|
{
|
|
|
|
foreach (self::SEARCHABLE_ENTITIES as $entity) {
|
|
|
|
$this->call('scout:import', ['model' => $entity]);
|
|
|
|
}
|
|
|
|
|
2022-07-29 06:47:10 +00:00
|
|
|
return self::SUCCESS;
|
2020-12-23 10:53:17 +00:00
|
|
|
}
|
|
|
|
}
|