koel/app/Console/Commands/ImportSearchableEntitiesCommand.php

34 lines
742 B
PHP
Raw Normal View History

2020-12-23 10:53:17 +00:00
<?php
namespace App\Console\Commands;
use App\Models\Album;
use App\Models\Artist;
use App\Models\Playlist;
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,
Playlist::class,
Podcast::class,
2020-12-23 10:53:17 +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
}
}