PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.4.5
Fluent Support – Helpdesk & Customer Support Ticket System v2.4.5
2.4.5 2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 All 69 releases
← All changes | app/Models/Agent.php +37 -1 1.10.4 → 2.4.5 View file →
@@ -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 {
@@ -54,7 +70,27 @@
54 70
55 71 return $this->hasMany(
56 72 $class, $foreign_key, 'id'
57 73 );
74 + }
75 +
76 + public function groups()
77 + {
78 + return $this->belongsToMany(
79 + AgentGroup::class, 'fs_tag_pivot', 'source_id', 'tag_id'
80 + )->wherePivot('source_type', 'agent_group');
81 + }
82 +
83 + public function scopeMentionBy($query, $search)
84 + {
85 + if (!$search) {
86 + return $query;
87 + }
88 +
89 + return $query->where(function ($q) use ($search) {
90 + $q->where('first_name', 'LIKE', '%' . $search . '%')
91 + ->orWhere('last_name', 'LIKE', '%' . $search . '%')
92 + ->orWhere('email', 'LIKE', '%' . $search . '%');
93 + });
58 94 }
59 95
60 96 }