Files
animethemes-server/app/Pivots/Wiki/AnimeThemeEntryVideo.php
T
2026-04-02 12:39:11 -03:00

94 lines
2.8 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Pivots\Wiki;
use App\Events\Pivot\Wiki\AnimeThemeEntryVideo\AnimeThemeEntryVideoCreated;
use App\Events\Pivot\Wiki\AnimeThemeEntryVideo\AnimeThemeEntryVideoDeleted;
use App\Models\Wiki\Anime\Theme\AnimeThemeEntry;
use App\Models\Wiki\Video;
use App\Pivots\BasePivot;
use Database\Factories\Pivots\Wiki\AnimeThemeEntryVideoFactory;
use Illuminate\Database\Eloquent\Attributes\Table;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* @property AnimeThemeEntry $animethemeentry
* @property int $entry_id
* @property Video $video
* @property int $video_id
*
* @method static AnimeThemeEntryVideoFactory factory(...$parameters)
*/
#[Table(AnimeThemeEntryVideo::TABLE)]
class AnimeThemeEntryVideo extends BasePivot
{
final public const string TABLE = 'anime_theme_entry_video';
final public const string ATTRIBUTE_ENTRY = 'entry_id';
final public const string ATTRIBUTE_VIDEO = 'video_id';
final public const string RELATION_ANIME = 'animethemeentry.animetheme.anime';
final public const string RELATION_ARTISTS = 'animethemeentry.animetheme.song.artists';
final public const string RELATION_ENTRY = 'animethemeentry';
final public const string RELATION_IMAGES = 'animethemeentry.animetheme.anime.images';
final public const string RELATION_SONG = 'animethemeentry.animetheme.song';
final public const string RELATION_VIDEO = 'video';
/**
* The event map for the model.
*
* Allows for object-based events for native Eloquent events.
*
* @var array<string, class-string>
*/
protected $dispatchesEvents = [
'created' => AnimeThemeEntryVideoCreated::class,
'deleted' => AnimeThemeEntryVideoDeleted::class,
];
/**
* The attributes that are mass assignable.
*
* @var list<string>
*/
protected $fillable = [
AnimeThemeEntryVideo::ATTRIBUTE_ENTRY,
AnimeThemeEntryVideo::ATTRIBUTE_VIDEO,
];
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
AnimeThemeEntryVideo::ATTRIBUTE_ENTRY => 'int',
AnimeThemeEntryVideo::ATTRIBUTE_VIDEO => 'int',
];
}
/**
* Gets the video that owns the video entry.
*
* @return BelongsTo<Video, $this>
*/
public function video(): BelongsTo
{
return $this->belongsTo(Video::class, AnimeThemeEntryVideo::ATTRIBUTE_VIDEO);
}
/**
* Gets the entry that owns the video entry.
*
* @return BelongsTo<AnimeThemeEntry, $this>
*/
public function animethemeentry(): BelongsTo
{
return $this->belongsTo(AnimeThemeEntry::class, AnimeThemeEntryVideo::ATTRIBUTE_ENTRY);
}
}