*/ protected $fillable = [ PlaylistTrack::ATTRIBUTE_ENTRY, PlaylistTrack::ATTRIBUTE_PLAYLIST, PlaylistTrack::ATTRIBUTE_VIDEO, ]; /** * The event map for the model. * * Allows for object-based events for native Eloquent events. * * @var array */ protected $dispatchesEvents = [ 'created' => TrackCreated::class, 'deleted' => TrackDeleted::class, 'restored' => TrackRestored::class, 'updated' => TrackUpdated::class, ]; /** * The table associated with the model. * * @var string */ protected $table = PlaylistTrack::TABLE; /** * The primary key associated with the table. * * @var string */ protected $primaryKey = PlaylistTrack::ATTRIBUTE_ID; /** * Get the route key for the model. * * @return string * * @noinspection PhpMissingParentCallCommonInspection */ public function getRouteKeyName(): string { return HasHashids::ATTRIBUTE_HASHID; } /** * Get the numbers used to encode the model's hashids. * * @return array */ public function hashids(): array { return [ $this->playlist_id, $this->track_id, ]; } /** * Get name. * * @return string */ public function getName(): string { return strval($this->getKey()); } /** * Get subtitle. * * @return string */ public function getSubtitle(): string { $subtitle = Str::of("($this->hashid) "); $user = $this->playlist->user; if ($user) { $subtitle = $subtitle ->append($user->getName()) ->append(' - '); } $subtitle = $subtitle->append($this->playlist->getName()); return $subtitle->__toString(); } /** * Get the entry of the track. * * @return BelongsTo */ public function animethemeentry(): BelongsTo { return $this->belongsTo(AnimeThemeEntry::class, PlaylistTrack::ATTRIBUTE_ENTRY); } /** * Get the playlist the track belongs to. * * @return BelongsTo */ public function playlist(): BelongsTo { return $this->belongsTo(Playlist::class, PlaylistTrack::ATTRIBUTE_PLAYLIST); } /** * Get the previous track. * * @return BelongsTo */ public function previous(): BelongsTo { return $this->belongsTo(PlaylistTrack::class, PlaylistTrack::ATTRIBUTE_PREVIOUS); } /** * Get the next track. * * @return BelongsTo */ public function next(): BelongsTo { return $this->belongsTo(PlaylistTrack::class, PlaylistTrack::ATTRIBUTE_NEXT); } /** * Get the video of the track. * * @return BelongsTo */ public function video(): BelongsTo { return $this->belongsTo(Video::class, PlaylistTrack::ATTRIBUTE_VIDEO); } }