afterCommit = true; } public function handle(MeilisearchClient $client): void { $artwork = Artwork::with([ 'user', 'group', 'tags', 'categories.contentType', 'stats', 'awardStat', ])->find($this->artworkId); if (! $artwork) { return; } if (! $artwork->is_public || ! $artwork->is_approved || ! $artwork->published_at) { // Not eligible — remove from index if present. $client->index($artwork->searchableAs())->deleteDocument($this->artworkId); return; } $document = $artwork->toSearchableArray(); $client->index($artwork->searchableAs())->addDocuments([$document]); } public function failed(\Throwable $e): void { Log::error('IndexArtworkJob failed', [ 'artwork_id' => $this->artworkId, 'error' => $e->getMessage(), ]); } }