*/ protected $dispatchesEvents = [ 'created' => FeaturedThemeCreated::class, 'deleted' => FeaturedThemeDeleted::class, 'updated' => FeaturedThemeUpdated::class, ]; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ FeaturedTheme::ATTRIBUTE_END_AT, FeaturedTheme::ATTRIBUTE_ENTRY, FeaturedTheme::ATTRIBUTE_START_AT, FeaturedTheme::ATTRIBUTE_USER, FeaturedTheme::ATTRIBUTE_VIDEO, ]; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ FeaturedTheme::ATTRIBUTE_END_AT => 'datetime', FeaturedTheme::ATTRIBUTE_START_AT => 'datetime', ]; } public function getName(): string { return Str::of($this->start_at->format(AllowedDateFormat::YMD->value)) ->append(' - ') ->append($this->end_at->format(AllowedDateFormat::YMD->value)) ->__toString(); } public function getSubtitle(): string { return $this->animethemeentry === null ? $this->getName() : $this->animethemeentry->getName(); } /** * Get the user that recommended the featured theme. * * @return BelongsTo */ public function user(): BelongsTo { return $this->belongsTo(User::class, FeaturedTheme::ATTRIBUTE_USER); } /** * @return BelongsTo */ public function animethemeentry(): BelongsTo { return $this->belongsTo(AnimeThemeEntry::class, FeaturedTheme::ATTRIBUTE_ENTRY); } /** * @return BelongsTo */ public function video(): BelongsTo { return $this->belongsTo(Video::class, FeaturedTheme::ATTRIBUTE_VIDEO); } }