44 lines
990 B
PHP
44 lines
990 B
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\DynamicPage;
|
|
use App\Models\News;
|
|
use App\Models\Document;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
class UpdateMeilisearch extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'update-meilisearch';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Command description';
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*/
|
|
public function handle()
|
|
{
|
|
$models = [DynamicPage::class, News::class, Document::class];
|
|
$locales = ['fr', 'en'];
|
|
|
|
foreach ($locales as $locale) {
|
|
$this->info("Import {$locale}...");
|
|
app()->setLocale($locale);
|
|
|
|
foreach ($models as $model) {
|
|
$this->call('scout:import', ['model' => $model]);
|
|
}
|
|
}
|
|
}
|
|
}
|