public function getAppointmentsCountAttribute()
    {
        // If relation is not loaded already, let's do it first
        if (!array_key_exists('appointmentsCount', $this->relations)) {
            $this->load('appointmentsCount');
        }

        $related = $this->getRelation('appointmentsCount');

        // Return the count directly
        return ($related->count() > 0) ? (int) $related->first()->aggregate : 0;
    }