IndexOpenSearch.php 869 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Services\OpenSearchService;
  5. use Illuminate\Support\Facades\App;
  6. class IndexOpenSearch extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'app:index-open-search';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = '如果是新的索引 全量更新openSearch';
  20. /**
  21. * Execute the console command.
  22. */
  23. public function handle()
  24. {
  25. //
  26. $service = app(OpenSearchService::class);
  27. if ($service->count() === 0) {
  28. $this->call('opensearch:index-pali');
  29. } else {
  30. if (App::environment('local')) {
  31. $this->info('data exist');
  32. }
  33. }
  34. }
  35. }