src/Models/Contact.php
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;
    }
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;
    }
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 ; }
get AppointmentsCount.

@return int Count of Appointments held by this Contact
get AppointmentsCount .