*/ protected $fillable = [ FeaturedTheme::ATTRIBUTE_END_AT, FeaturedTheme::ATTRIBUTE_ENTRY, FeaturedTheme::ATTRIBUTE_START_AT, FeaturedTheme::ATTRIBUTE_USER, FeaturedTheme::ATTRIBUTE_VIDEO, ]; /** * The event map for the model. * * Allows for object-based events for native Eloquent events. * * @var array */ protected $dispatchesEvents = [ 'created' => FeaturedThemeCreated::class, 'deleted' => FeaturedThemeDeleted::class, 'restored' => FeaturedThemeRestored::class, 'updated' => FeaturedThemeUpdated::class, ]; /** * The table associated with the model. * * @var string */ protected $table = FeaturedTheme::TABLE; /** * The primary key associated with the table. * * @var string */ protected $primaryKey = FeaturedTheme::ATTRIBUTE_ID; /** * The attributes that should be cast. * * @var array */ protected $casts = [ FeaturedTheme::ATTRIBUTE_END_AT => 'datetime', FeaturedTheme::ATTRIBUTE_START_AT => 'datetime', ]; /** * Get name. * * @return string */ public function getName(): string { return Str::of($this->start_at->format(AllowedDateFormat::YMD->value)) ->append(' - ') ->append($this->end_at->format(AllowedDateFormat::YMD->value)) ->__toString(); } /** * Get subtitle. * * @return string */ 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); } /** * Get the entry for the featured video. * * @return BelongsTo */ public function animethemeentry(): BelongsTo { return $this->belongsTo(AnimeThemeEntry::class, FeaturedTheme::ATTRIBUTE_ENTRY); } /** * Get the video to feature. * * @return BelongsTo */ public function video(): BelongsTo { return $this->belongsTo(Video::class, FeaturedTheme::ATTRIBUTE_VIDEO); } }