-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
36 changed files
with
1,627 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events\Wiki\Group; | ||
|
||
use App\Contracts\Events\UpdateRelatedIndicesEvent; | ||
use App\Events\Base\Wiki\WikiCreatedEvent; | ||
use App\Models\Wiki\Anime\AnimeTheme; | ||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; | ||
use App\Models\Wiki\Group; | ||
use App\Models\Wiki\Video; | ||
|
||
/** | ||
* Class GroupCreated. | ||
* | ||
* @extends WikiCreatedEvent<Group> | ||
*/ | ||
class GroupCreated extends WikiCreatedEvent implements UpdateRelatedIndicesEvent | ||
{ | ||
/** | ||
* Create a new event instance. | ||
* | ||
* @param Group $group | ||
*/ | ||
public function __construct(Group $group) | ||
{ | ||
parent::__construct($group); | ||
} | ||
|
||
/** | ||
* Get the model that has fired this event. | ||
* | ||
* @return Group | ||
*/ | ||
public function getModel(): Group | ||
{ | ||
return $this->model; | ||
} | ||
|
||
/** | ||
* Get the description for the Discord message payload. | ||
* | ||
* @return string | ||
*/ | ||
protected function getDiscordMessageDescription(): string | ||
{ | ||
return "Group '**{$this->getModel()->getName()}**' has been created."; | ||
} | ||
|
||
/** | ||
* Perform updates on related indices. | ||
* | ||
* @return void | ||
*/ | ||
public function updateRelatedIndices(): void | ||
{ | ||
$group = $this->getModel()->load(Group::RELATION_VIDEOS); | ||
|
||
$group->animethemes->each(function (AnimeTheme $theme) { | ||
$theme->searchable(); | ||
$theme->animethemeentries->each(function (AnimeThemeEntry $entry) { | ||
$entry->searchable(); | ||
$entry->videos->each(fn (Video $video) => $video->searchable()); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events\Wiki\Group; | ||
|
||
use App\Contracts\Events\UpdateRelatedIndicesEvent; | ||
use App\Events\Base\Wiki\WikiDeletedEvent; | ||
use App\Models\Wiki\Anime\AnimeTheme; | ||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; | ||
use App\Models\Wiki\Group; | ||
use App\Models\Wiki\Video; | ||
use App\Nova\Resources\Wiki\Group as GroupResource; | ||
|
||
/** | ||
* Class GroupDeleted. | ||
* | ||
* @extends WikiDeletedEvent<Group> | ||
*/ | ||
class GroupDeleted extends WikiDeletedEvent implements UpdateRelatedIndicesEvent | ||
{ | ||
/** | ||
* Create a new event instance. | ||
* | ||
* @param Group $group | ||
*/ | ||
public function __construct(Group $group) | ||
{ | ||
parent::__construct($group); | ||
} | ||
|
||
/** | ||
* Get the model that has fired this event. | ||
* | ||
* @return Group | ||
*/ | ||
public function getModel(): Group | ||
{ | ||
return $this->model; | ||
} | ||
|
||
/** | ||
* Get the description for the Discord message payload. | ||
* | ||
* @return string | ||
*/ | ||
protected function getDiscordMessageDescription(): string | ||
{ | ||
return "Group '**{$this->getModel()->getName()}**' has been deleted."; | ||
} | ||
|
||
/** | ||
* Get the message for the nova notification. | ||
* | ||
* @return string | ||
*/ | ||
protected function getNotificationMessage(): string | ||
{ | ||
return "Group '{$this->getModel()->getName()}' has been deleted. It will be automatically pruned in one week. Please review."; | ||
} | ||
|
||
/** | ||
* Get the URL for the nova notification. | ||
* | ||
* @return string | ||
*/ | ||
protected function getNovaNotificationUrl(): string | ||
{ | ||
$uriKey = GroupResource::uriKey(); | ||
|
||
return "/resources/$uriKey/{$this->getModel()->getKey()}"; | ||
} | ||
|
||
/** | ||
* Perform updates on related indices. | ||
* | ||
* @return void | ||
*/ | ||
public function updateRelatedIndices(): void | ||
{ | ||
$group = $this->getModel()->load(Group::RELATION_VIDEOS); | ||
|
||
$group->animethemes->each(function (AnimeTheme $theme) { | ||
$theme->searchable(); | ||
$theme->animethemeentries->each(function (AnimeThemeEntry $entry) { | ||
$entry->searchable(); | ||
$entry->videos->each(fn (Video $video) => $video->searchable()); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events\Wiki\Group; | ||
|
||
use App\Contracts\Events\UpdateRelatedIndicesEvent; | ||
use App\Events\BaseEvent; | ||
use App\Models\Wiki\Anime\AnimeTheme; | ||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; | ||
use App\Models\Wiki\Group; | ||
use App\Models\Wiki\Video; | ||
|
||
/** | ||
* Class GroupDeleting. | ||
* | ||
* @extends BaseEvent<Group> | ||
*/ | ||
class GroupDeleting extends BaseEvent implements UpdateRelatedIndicesEvent | ||
{ | ||
/** | ||
* Create a new event instance. | ||
* | ||
* @param Group $group | ||
*/ | ||
public function __construct(Group $group) | ||
{ | ||
parent::__construct($group); | ||
} | ||
|
||
/** | ||
* Get the model that has fired this event. | ||
* | ||
* @return Group | ||
*/ | ||
public function getModel(): Group | ||
{ | ||
return $this->model; | ||
} | ||
|
||
/** | ||
* Perform cascading deletes. | ||
* | ||
* @return void | ||
*/ | ||
public function updateRelatedIndices(): void | ||
{ | ||
$group = $this->getModel()->load(Group::RELATION_VIDEOS); | ||
|
||
if ($group->isForceDeleting()) { | ||
$group->animethemes->each(function (AnimeTheme $theme) { | ||
AnimeTheme::withoutEvents(function () use ($theme) { | ||
$theme->theme_group()->dissociate(); | ||
$theme->save(); | ||
}); | ||
$theme->searchable(); | ||
$theme->animethemeentries->each(function (AnimeThemeEntry $entry) { | ||
$entry->searchable(); | ||
$entry->videos->each(fn (Video $video) => $video->searchable()); | ||
}); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events\Wiki\Group; | ||
|
||
use App\Contracts\Events\UpdateRelatedIndicesEvent; | ||
use App\Events\Base\Wiki\WikiRestoredEvent; | ||
use App\Models\Wiki\Anime\AnimeTheme; | ||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; | ||
use App\Models\Wiki\Group; | ||
use App\Models\Wiki\Video; | ||
|
||
/** | ||
* Class GroupRestored. | ||
* | ||
* @extends WikiRestoredEvent<Group> | ||
*/ | ||
class GroupRestored extends WikiRestoredEvent implements UpdateRelatedIndicesEvent | ||
{ | ||
/** | ||
* Create a new event instance. | ||
* | ||
* @param Group $group | ||
*/ | ||
public function __construct(Group $group) | ||
{ | ||
parent::__construct($group); | ||
} | ||
|
||
/** | ||
* Get the model that has fired this event. | ||
* | ||
* @return Group | ||
*/ | ||
public function getModel(): Group | ||
{ | ||
return $this->model; | ||
} | ||
|
||
/** | ||
* Get the description for the Discord message payload. | ||
* | ||
* @return string | ||
*/ | ||
protected function getDiscordMessageDescription(): string | ||
{ | ||
return "Group '**{$this->getModel()->getName()}**' has been restored."; | ||
} | ||
|
||
/** | ||
* Perform cascading deletes. | ||
* | ||
* @return void | ||
*/ | ||
public function updateRelatedIndices(): void | ||
{ | ||
$group = $this->getModel()->load(Group::RELATION_VIDEOS); | ||
|
||
$group->animethemes->each(function (AnimeTheme $theme) { | ||
$theme->searchable(); | ||
$theme->animethemeentries->each(function (AnimeThemeEntry $entry) { | ||
$entry->searchable(); | ||
$entry->videos->each(fn (Video $video) => $video->searchable()); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Events\Wiki\Group; | ||
|
||
use App\Contracts\Events\UpdateRelatedIndicesEvent; | ||
use App\Events\Base\Wiki\WikiUpdatedEvent; | ||
use App\Models\Wiki\Anime\AnimeTheme; | ||
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry; | ||
use App\Models\Wiki\Group; | ||
use App\Models\Wiki\Video; | ||
|
||
/** | ||
* Class GroupUpdated. | ||
* | ||
* @extends WikiUpdatedEvent<Group> | ||
*/ | ||
class GroupUpdated extends WikiUpdatedEvent implements UpdateRelatedIndicesEvent | ||
{ | ||
/** | ||
* Create a new event instance. | ||
* | ||
* @param Group $group | ||
*/ | ||
public function __construct(Group $group) | ||
{ | ||
parent::__construct($group); | ||
$this->initializeEmbedFields($group); | ||
} | ||
|
||
/** | ||
* Get the model that has fired this event. | ||
* | ||
* @return Group | ||
*/ | ||
public function getModel(): Group | ||
{ | ||
return $this->model; | ||
} | ||
|
||
/** | ||
* Get the description for the Discord message payload. | ||
* | ||
* @return string | ||
*/ | ||
protected function getDiscordMessageDescription(): string | ||
{ | ||
return "Group '**{$this->getModel()->getName()}**' has been updated."; | ||
} | ||
|
||
/** | ||
* Perform updates on related indices. | ||
* | ||
* @return void | ||
*/ | ||
public function updateRelatedIndices(): void | ||
{ | ||
$group = $this->getModel()->load(Group::RELATION_VIDEOS); | ||
|
||
$group->animethemes->each(function (AnimeTheme $theme) { | ||
$theme->searchable(); | ||
$theme->animethemeentries->each(function (AnimeThemeEntry $entry) { | ||
$entry->searchable(); | ||
$entry->videos->each(fn (Video $video) => $video->searchable()); | ||
}); | ||
}); | ||
} | ||
} |
Oops, something went wrong.