| @@ 226-237 (lines=12) @@ | ||
| 223 | * |
|
| 224 | * @return int Count of Contacts with real User held by this Business |
|
| 225 | */ |
|
| 226 | public function getSubscriptionsCountAttribute() |
|
| 227 | { |
|
| 228 | // if relation is not loaded already, let's do it first |
|
| 229 | if (!array_key_exists('subscriptionsCount', $this->relations)) { |
|
| 230 | $this->load('subscriptionsCount'); |
|
| 231 | } |
|
| 232 | ||
| 233 | $related = $this->getRelation('subscriptionsCount'); |
|
| 234 | ||
| 235 | // then return the count directly |
|
| 236 | return ($related->count() > 0) ? (int) $related->first()->aggregate : 0; |
|
| 237 | } |
|
| 238 | ||
| 239 | /////////////// |
|
| 240 | // Overrides // |
|
| @@ 124-135 (lines=12) @@ | ||
| 121 | * |
|
| 122 | * @return int Count of Appointments held by this Contact |
|
| 123 | */ |
|
| 124 | public function getAppointmentsCountAttribute() |
|
| 125 | { |
|
| 126 | // If relation is not loaded already, let's do it first |
|
| 127 | if (!array_key_exists('appointmentsCount', $this->relations)) { |
|
| 128 | $this->load('appointmentsCount'); |
|
| 129 | } |
|
| 130 | ||
| 131 | $related = $this->getRelation('appointmentsCount'); |
|
| 132 | ||
| 133 | // Return the count directly |
|
| 134 | return ($related->count() > 0) ? (int) $related->first()->aggregate : 0; |
|
| 135 | } |
|
| 136 | ||
| 137 | /////////////// |
|
| 138 | // Presenter // |
|