| @@ 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 // |
|
| @@ 186-197 (lines=12) @@ | ||
| 183 | * |
|
| 184 | * @return int Count of Contacts with real User held by this Business |
|
| 185 | */ |
|
| 186 | public function getSubscriptionsCountAttribute() |
|
| 187 | { |
|
| 188 | // if relation is not loaded already, let's do it first |
|
| 189 | if (!array_key_exists('subscriptionsCount', $this->relations)) { |
|
| 190 | $this->load('subscriptionsCount'); |
|
| 191 | } |
|
| 192 | ||
| 193 | $related = $this->getRelation('subscriptionsCount'); |
|
| 194 | ||
| 195 | // then return the count directly |
|
| 196 | return ($related->count() > 0) ? (int) $related->first()->aggregate : 0; |
|
| 197 | } |
|
| 198 | ||
| 199 | /////////////// |
|
| 200 | // Overrides // |
|