*/ class SongUpdated extends WikiUpdatedEvent implements UpdateRelatedIndicesEvent { /** * Create a new event instance. * * @param Song $song */ public function __construct(Song $song) { parent::__construct($song); $this->initializeEmbedFields($song); } /** * Get the model that has fired this event. * * @return Song */ public function getModel(): Song { return $this->model; } /** * Get the description for the Discord message payload. * * @return string */ protected function getDiscordMessageDescription(): string { return "Song '**{$this->getModel()->getName()}**' has been updated."; } /** * Perform updates on related indices. * * @return void */ public function updateRelatedIndices(): void { $song = $this->getModel()->load([Song::RELATION_ARTISTS, Song::RELATION_VIDEOS]); $song->artists->each(fn (Artist $artist) => $artist->searchable()); $song->animethemes->each(function (AnimeTheme $theme) { $theme->searchable(); $theme->animethemeentries->each(function (AnimeThemeEntry $entry) { $entry->searchable(); $entry->videos->each(fn (Video $video) => $video->searchable()); }); }); } }