mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Events\Wiki\Anime\Synonym;
|
|
|
|
use App\Contracts\Events\UpdateRelatedIndicesEvent;
|
|
use App\Events\Base\Wiki\WikiUpdatedEvent;
|
|
use App\Models\Wiki\Anime\AnimeSynonym;
|
|
use App\Models\Wiki\Anime\AnimeTheme;
|
|
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
|
|
use App\Models\Wiki\Series;
|
|
use App\Models\Wiki\Video;
|
|
|
|
/**
|
|
* @extends WikiUpdatedEvent<AnimeSynonym>
|
|
*/
|
|
class SynonymUpdated extends WikiUpdatedEvent implements UpdateRelatedIndicesEvent
|
|
{
|
|
public function __construct(AnimeSynonym $synonym)
|
|
{
|
|
parent::__construct($synonym);
|
|
$this->initializeEmbedFields($synonym);
|
|
}
|
|
|
|
protected function getDiscordMessageDescription(): string
|
|
{
|
|
return "Synonym '**{$this->getModel()->getName()}**' has been updated for Anime '**{$this->getModel()->anime->getName()}**'.";
|
|
}
|
|
|
|
public function updateRelatedIndices(): void
|
|
{
|
|
$synonym = $this->getModel()->load([
|
|
AnimeSynonym::RELATION_SERIES,
|
|
AnimeSynonym::RELATION_VIDEOS,
|
|
]);
|
|
|
|
$synonym->anime->searchable();
|
|
$synonym->anime->series->each(fn (Series $series) => $series->searchable());
|
|
$synonym->anime->animethemes->each(function (AnimeTheme $theme): void {
|
|
$theme->searchable();
|
|
$theme->animethemeentries->each(function (AnimeThemeEntry $entry): void {
|
|
$entry->searchable();
|
|
$entry->videos->each(fn (Video $video) => $video->searchable());
|
|
});
|
|
});
|
|
}
|
|
}
|