| @@ -26,8 +26,25 @@ | ||
| 26 | 26 | public function getSearchableFields(){ |
| 27 | 27 | return $this->searchable; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | + /** | |
| 31 | + * Agent ids, cached per request. Reporting filters on these ids because | |
| 32 | + * whereHas('person') hits fs_persons, which has no person_type index. | |
| 33 | + * | |
| 34 | + * @return array | |
| 35 | + */ | |
| 36 | + public static function getAgentIds() | |
| 37 | + { | |
| 38 | + static $agentIds = null; | |
| 39 | + | |
| 40 | + if (is_null($agentIds)) { | |
| 41 | + $agentIds = array_map('intval', static::query()->pluck('id')->all()); | |
| 42 | + } | |
| 43 | + | |
| 44 | + return $agentIds; | |
| 45 | + } | |
| 46 | + | |
| 30 | 47 | public static function boot() |
| 31 | 48 | { |
| 32 | 49 | parent::boot(); |
| 33 | 50 | |
| @@ -42,9 +59,8 @@ | ||
| 42 | 59 | } |
| 43 | 60 | |
| 44 | 61 | |
| 45 | 62 | /** |
| 46 | - * One2Many: Customer has to many Click Tickets | |
| 47 | 63 | * @return Model Collection |
| 48 | 64 | */ |
| 49 | 65 | public function tickets() |
| 50 | 66 | { |