| @@ 164-175 (lines=12) @@ | ||
| 161 | * |
|
| 162 | * @return int Count of Contacts with real User held by this Business |
|
| 163 | */ |
|
| 164 | public function getSubscriptionsCountAttribute() |
|
| 165 | { |
|
| 166 | // if relation is not loaded already, let's do it first |
|
| 167 | if (!array_key_exists('subscriptionsCount', $this->relations)) { |
|
| 168 | $this->load('subscriptionsCount'); |
|
| 169 | } |
|
| 170 | ||
| 171 | $related = $this->getRelation('subscriptionsCount'); |
|
| 172 | ||
| 173 | // then return the count directly |
|
| 174 | return ($related->count() > 0) ? (int) $related->first()->aggregate : 0; |
|
| 175 | } |
|
| 176 | ||
| 177 | /////////////// |
|
| 178 | // Overrides // |
|
| @@ 95-106 (lines=12) @@ | ||
| 92 | * |
|
| 93 | * @return int Count of Appointments held by this Contact |
|
| 94 | */ |
|
| 95 | public function getAppointmentsCountAttribute() |
|
| 96 | { |
|
| 97 | // If relation is not loaded already, let's do it first |
|
| 98 | if (!array_key_exists('appointmentsCount', $this->relations)) { |
|
| 99 | $this->load('appointmentsCount'); |
|
| 100 | } |
|
| 101 | ||
| 102 | $related = $this->getRelation('appointmentsCount'); |
|
| 103 | ||
| 104 | // Return the count directly |
|
| 105 | return ($related->count() > 0) ? (int) $related->first()->aggregate : 0; |
|
| 106 | } |
|
| 107 | ||
| 108 | /////////////// |
|
| 109 | // Presenter // |
|