$playlists * @property Collection|array $playlist_folders * @property PersonalAccessToken $currentAccessToken * @property ?Carbon $invitation_accepted_at * @property ?User $invitedBy * @property ?string $invitation_token * @property ?Carbon $invited_at * @property-read bool $is_prospect */ class User extends Authenticatable { use HasApiTokens; use HasFactory; use Notifiable; protected $guarded = ['id']; protected $hidden = ['password', 'remember_token', 'created_at', 'updated_at', 'invitation_accepted_at']; protected $appends = ['avatar']; protected $casts = [ 'is_admin' => 'bool', 'preferences' => UserPreferencesCast::class, ]; public function invitedBy(): BelongsTo { return $this->belongsTo(User::class, 'invited_by_id'); } public function playlists(): HasMany { return $this->hasMany(Playlist::class); } public function playlist_folders(): HasMany // @phpcs:ignore { return $this->hasMany(PlaylistFolder::class); } public function interactions(): HasMany { return $this->hasMany(Interaction::class); } protected function avatar(): Attribute { return Attribute::get( fn () => sprintf('https://www.gravatar.com/avatar/%s?s=192&d=robohash', md5($this->email)) ); } /** * Get the user's Last.fm session key. */ protected function lastfmSessionKey(): Attribute { return Attribute::get(fn (): ?string => $this->preferences->lastFmSessionKey); } protected function isProspect(): Attribute { return Attribute::get(fn (): bool => (bool) $this->invitation_token); } /** * Determine if the user is connected to Last.fm. */ public function connectedToLastfm(): bool { return (bool) $this->lastfm_session_key; } }