| @@ 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 // |
|
| @@ 175-186 (lines=12) @@ | ||
| 172 | * |
|
| 173 | * @return int Count of Contacts with real User held by this Business |
|
| 174 | */ |
|
| 175 | public function getSubscriptionsCountAttribute() |
|
| 176 | { |
|
| 177 | // if relation is not loaded already, let's do it first |
|
| 178 | if (!array_key_exists('subscriptionsCount', $this->relations)) { |
|
| 179 | $this->load('subscriptionsCount'); |
|
| 180 | } |
|
| 181 | ||
| 182 | $related = $this->getRelation('subscriptionsCount'); |
|
| 183 | ||
| 184 | // then return the count directly |
|
| 185 | return ($related->count() > 0) ? (int) $related->first()->aggregate : 0; |
|
| 186 | } |
|
| 187 | ||
| 188 | /////////////// |
|
| 189 | // Overrides // |
|