| Conditions | 3 |
| Paths | 4 |
| Total Lines | 12 |
| Code Lines | 5 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 4 |
| CRAP Score | 3.072 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 8 | protected function getCountAttribute($field) |
|
| 34 | { |
||
| 35 | // if relation is not loaded already, let's do it first |
||
| 36 | 8 | if (!array_key_exists($field, $this->relations)) { |
|
| 37 | $this->load($field); |
||
| 38 | } |
||
| 39 | |||
| 40 | 8 | $related = $this->getRelation($field); |
|
| 41 | |||
| 42 | // then return the count directly |
||
| 43 | 8 | return ($related) ? (int) $related->aggregate : 0; |
|
| 44 | } |
||
| 45 | } |
||
| 46 |