*/ protected $fillable = [ ExternalEntry::ATTRIBUTE_ANIME, ExternalEntry::ATTRIBUTE_PROFILE, ExternalEntry::ATTRIBUTE_IS_FAVORITE, ExternalEntry::ATTRIBUTE_SCORE, ExternalEntry::ATTRIBUTE_WATCH_STATUS, ]; /** * The table associated with the model. * * @var string */ protected $table = ExternalEntry::TABLE; /** * The primary key associated with the table. * * @var string */ protected $primaryKey = ExternalEntry::ATTRIBUTE_ID; /** * Get the attributes that should be cast. * * @return array */ protected function casts(): array { return [ ExternalEntry::ATTRIBUTE_IS_FAVORITE => 'bool', ExternalEntry::ATTRIBUTE_WATCH_STATUS => ExternalEntryWatchStatus::class, ]; } /** * Get name. * * @return string */ public function getName(): string { return strval($this->getKey()); } /** * Get subtitle. * * @return string */ public function getSubtitle(): string { return $this->anime->getName(); } /** * Get the eager loads needed to the subtitle. * * @return array */ public static function getEagerLoadsForSubtitle(): array { return [ ExternalEntry::RELATION_ANIME, ]; } /** * Get the fields to perform an update. * * @return array */ public static function fieldsForUpdate(): array { return [ ExternalEntry::ATTRIBUTE_IS_FAVORITE, ExternalEntry::ATTRIBUTE_SCORE, ExternalEntry::ATTRIBUTE_WATCH_STATUS, ]; } /** * Get the anime that owns the user external entry. * * @return BelongsTo */ public function anime(): BelongsTo { return $this->belongsTo(Anime::class, ExternalEntry::ATTRIBUTE_ANIME); } /** * Get the user profile that owns the user profile. * * @return BelongsTo */ public function externalprofile(): BelongsTo { return $this->belongsTo(ExternalProfile::class, ExternalEntry::ATTRIBUTE_PROFILE); } }