mirror of
https://github.com/koel/koel
synced 2025-02-17 13:58:28 +00:00
feat: add import:search command
This commit is contained in:
parent
84a72d284c
commit
5293bd9da0
1 changed files with 35 additions and 0 deletions
35
app/Console/Commands/ImportSearchableEntitiesCommand.php
Normal file
35
app/Console/Commands/ImportSearchableEntitiesCommand.php
Normal file
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Album;
|
||||
use App\Models\Artist;
|
||||
use App\Models\Playlist;
|
||||
use App\Models\Song;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ImportSearchableEntitiesCommand extends Command
|
||||
{
|
||||
private const SEARCHABLE_ENTITIES = [
|
||||
Song::class,
|
||||
Album::class,
|
||||
Artist::class,
|
||||
Playlist::class,
|
||||
];
|
||||
|
||||
protected $signature = 'search:import';
|
||||
protected $description = 'Import all searchable entities with Scout';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
foreach (self::SEARCHABLE_ENTITIES as $entity) {
|
||||
if (!class_exists($entity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->call('scout:import', ['model' => $entity]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue