mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
94 lines
2.8 KiB
PHP
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);
|
|
}
|
|
}
|