mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-25 16:24:35 +02:00
* feat: initial commit for feature management * style: fix StyleCI findings * fix(api): prohibit features of nonnull scope from API & fix(admin): wrong translate key * style: fix Static Analysis error
77 lines
1.6 KiB
PHP
77 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Constants\Config\ServiceConstants;
|
|
use App\Contracts\Events\DiscordMessageEvent;
|
|
use App\Models\BaseModel;
|
|
use Illuminate\Support\Facades\Config;
|
|
|
|
/**
|
|
* Class BasePivotEvent.
|
|
*
|
|
* @template TModelRelated of \App\Models\BaseModel
|
|
* @template TModelForeign of \App\Models\BaseModel
|
|
*/
|
|
abstract class BasePivotEvent implements DiscordMessageEvent
|
|
{
|
|
/**
|
|
* Create a new event instance.
|
|
*
|
|
* @param TModelRelated $related
|
|
* @param TModelForeign $foreign
|
|
*/
|
|
public function __construct(protected BaseModel $related, protected BaseModel $foreign)
|
|
{
|
|
}
|
|
|
|
/**
|
|
* Get the related model.
|
|
*
|
|
* @return TModelRelated
|
|
*/
|
|
public function getRelated(): BaseModel
|
|
{
|
|
return $this->related;
|
|
}
|
|
|
|
/**
|
|
* Get the foreign model.
|
|
*
|
|
* @return TModelForeign
|
|
*/
|
|
public function getForeign(): BaseModel
|
|
{
|
|
return $this->foreign;
|
|
}
|
|
|
|
/**
|
|
* Get Discord channel the message will be sent to.
|
|
*
|
|
* @return string
|
|
*/
|
|
public function getDiscordChannel(): string
|
|
{
|
|
return Config::get(ServiceConstants::DB_UPDATES_DISCORD_CHANNEL_QUALIFIED);
|
|
}
|
|
|
|
/**
|
|
* Determine if the message should be sent.
|
|
*
|
|
* @return bool
|
|
*/
|
|
public function shouldSendDiscordMessage(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the description for the Discord message payload.
|
|
*
|
|
* @return string
|
|
*/
|
|
abstract protected function getDiscordMessageDescription(): string;
|
|
}
|