*/ protected $fillable = [ Performance::ATTRIBUTE_SONG, Performance::ATTRIBUTE_ARTIST_TYPE, Performance::ATTRIBUTE_ARTIST_ID, Performance::ATTRIBUTE_ALIAS, Performance::ATTRIBUTE_AS, ]; /** * The event map for the model. * * Allows for object-based events for native Eloquent events. * * @var array */ protected $dispatchesEvents = [ 'created' => PerformanceCreated::class, 'deleted' => PerformanceDeleted::class, 'deleting' => PerformanceDeleting::class, 'restored' => PerformanceRestored::class, 'updated' => PerformanceUpdated::class, ]; /** * The table associated with the model. * * @var string */ protected $table = Performance::TABLE; /** * The primary key associated with the table. * * @var string */ protected $primaryKey = Performance::ATTRIBUTE_ID; /** * Get name. * * @return string */ public function getName(): string { return strval($this->getKey()); } /** * Get subtitle. * * @return string */ public function getSubtitle(): string { $this->loadMissing([ Performance::RELATION_SONG, ]); return $this->song->getName(); } /** * Get the eager loads needed to the subtitle. * * @return array */ public static function getEagerLoadsForSubtitle(): array { return [ Performance::RELATION_SONG, ]; } /** * Determine if the performance is a membership. * * @return bool */ public function isMembership(): bool { return $this->artist_type === Membership::class; } /** * Get the song that owns the performance. * * @return BelongsTo */ public function song(): BelongsTo { return $this->belongsTo(Song::class, Song::ATTRIBUTE_ID); } /** * Get the artist that owns the performance. * * @return MorphTo */ public function artist(): MorphTo { return $this->morphTo(); } /** * Alias of artist(). * * @return MorphTo */ public function membership(): MorphTo { return $this->artist(); } }