id); } /** * Queue an artwork for re-indexing after an update. */ public function update(Artwork $artwork): void { IndexArtworkJob::dispatch($artwork->id); } /** * Queue removal of an artwork from the index. */ public function delete(int $id): void { DeleteArtworkFromIndexJob::dispatch($id); } /** * Rebuild the entire artworks index in background chunks. * Run via: php artisan artworks:search-rebuild */ public function rebuildAll(int $chunkSize = 500): void { Artwork::with(['user', 'tags', 'categories', 'stats', 'awardStat']) ->public() ->published() ->orderBy('id') ->chunk($chunkSize, function ($artworks): void { foreach ($artworks as $artwork) { IndexArtworkJob::dispatch($artwork->id); } }); Log::info('ArtworkSearchIndexer::rebuildAll — jobs dispatched'); } }