belongsTo(User::class); } public function commentable() { return $this->morphTo(); } // For backward compatibility with Media public function media() { return $this->belongsTo(Media::class, 'commentable_id')->where('commentable_type', Media::class); } // For Music public function music() { return $this->belongsTo(Music::class, 'commentable_id')->where('commentable_type', Music::class); } // Check if comment belongs to current user public function getIsOwnerAttribute() { return auth()->check() && $this->user_id === auth()->id(); } // Add timestamps formatted public function getFormattedCreatedAtAttribute() { return $this->created_at->diffForHumans(); } protected $appends = ['is_owner', 'formatted_created_at']; }