PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.1.0
Fluent Support – Helpdesk & Customer Support Ticket System v2.1.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 1.5.5 1.5.6 All 67 releases
fluent-support / app / Models / Agent.php

Agent.php in Fluent Support – Helpdesk & Customer Support Ticket System 2.1.0, at app/Models/Agent.php

68 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentSupport\App\Models;
4
5 use FluentSupport\App\Models\Traits\AgentTrait;
6
7 class Agent extends Person
8 {
9 use AgentTrait;
10
11 protected static $type = 'agent';
12
13 protected $searchable = [
14 'id',
15 'first_name',
16 'last_name',
17 'email',
18 'address_line_1',
19 'address_line_2',
20 'country'
21 ];
22
23 /**
24 * @return array
25 */
26 public function getSearchableFields(){
27 return $this->searchable;
28 }
29
30 public static function boot()
31 {
32 parent::boot();
33
34 static::creating(function ($model) {
35 $model->person_type = static::$type;
36 $model->hash = md5(time().wp_generate_uuid4());
37 });
38
39 static::addGlobalScope(function ($builder) {
40 $builder->where('person_type', 'agent');
41 });
42 }
43
44
45 /**
46 * One2Many: Customer has to many Click Tickets
47 * @return Model Collection
48 */
49 public function tickets()
50 {
51 $foreign_key = self::$type . '_id';
52
53 $class = __NAMESPACE__ . '\Ticket';
54
55 return $this->hasMany(
56 $class, $foreign_key, 'id'
57 );
58 }
59
60 public function groups()
61 {
62 return $this->belongsToMany(
63 AgentGroup::class, 'fs_tag_pivot', 'source_id', 'tag_id'
64 )->wherePivot('source_type', 'agent_group');
65 }
66
67 }
68