<?php
 namespace App\Listeners\Search; use App\Events\TranslationUpdated; use App\Models\Announcement; use App\Models\BlogPost; use App\Models\KbArticle; class ReindexOnTranslationUpdate { public function handle(TranslationUpdated $event): void { $model = $event->model; $indexerClass = match (true) { $model instanceof Announcement => 'App\Services\Search\AnnouncementSearchIndexer', $model instanceof KbArticle => 'App\Services\Search\KnowledgebaseSearchIndexer', $model instanceof BlogPost => 'App\Services\Search\BlogSearchIndexer', default => null, }; if ($indexerClass === null || ! class_exists($indexerClass)) { return; } try { app($indexerClass)->reindex($model); } catch (\Throwable) { } } } 