1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace LPTracker\models; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use LPTracker\exceptions\LPTrackerSDKException; |
7
|
|
|
|
8
|
|
|
class CustomField extends Model |
9
|
|
|
{ |
10
|
|
|
|
11
|
|
|
protected $id; |
12
|
|
|
|
13
|
|
|
protected $projectId; |
14
|
|
|
|
15
|
|
|
protected $name; |
16
|
|
|
|
17
|
|
|
protected $type; |
18
|
|
|
|
19
|
|
|
protected $showInLeads; |
20
|
|
|
|
21
|
|
|
protected $showInDeals; |
22
|
|
|
|
23
|
|
|
protected $isMultiSelect; |
24
|
|
|
|
25
|
|
|
protected $isRequired; |
26
|
|
|
|
27
|
|
|
protected $description; |
28
|
|
|
|
29
|
|
|
protected $isMultiLine; |
30
|
|
|
|
31
|
|
|
public function __construct(array $data = []) |
32
|
|
|
{ |
33
|
|
|
if (isset($data['id'])) { |
34
|
|
|
$this->id = $data['id']; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
if (isset($data['project_id'])) { |
38
|
|
|
$this->projectId = $data['project_id']; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
if (isset($data['name'])) { |
42
|
|
|
$this->name = $data['name']; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if (isset($data['type'])) { |
46
|
|
|
$this->type = $data['type']; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
if (isset($data['show_in_leads'])) { |
50
|
|
|
$this->showInLeads = $data['show_in_leads']; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
if (isset($data['show_in_deals'])) { |
54
|
|
|
$this->showInDeals = $data['show_in_deals']; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
if (isset($data['is_multi_select'])) { |
58
|
|
|
$this->isMultiSelect = $data['is_multi_select']; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
if (isset($data['is_required'])) { |
62
|
|
|
$this->isRequired = $data['is_required']; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
if (isset($data['description'])) { |
66
|
|
|
$this->description = $data['description']; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
if (isset($data['is_multi_line'])) { |
70
|
|
|
$this->isMultiLine = $data['is_multi_line']; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @return array |
77
|
|
|
*/ |
78
|
|
|
public function toArray() |
79
|
|
|
{ |
80
|
|
|
return [ |
81
|
|
|
'id' => $this->id, |
82
|
|
|
'project_id' => $this->projectId, |
83
|
|
|
'name' => $this->name, |
84
|
|
|
'type' => $this->type, |
85
|
|
|
'show_in_leads' => $this->showInLeads, |
86
|
|
|
'show_in_deals' => $this->showInDeals, |
87
|
|
|
'is_multi_select' => $this->isMultiSelect, |
88
|
|
|
'is_required' => $this->isRequired, |
89
|
|
|
'description' => $this->description, |
90
|
|
|
'is_multi_line' => $this->isMultiLine |
91
|
|
|
]; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @return bool |
96
|
|
|
* @throws LPTrackerSDKException |
97
|
|
|
*/ |
98
|
|
|
public function validate() |
99
|
|
|
{ |
100
|
|
|
if (empty($this->id)) { |
101
|
|
|
throw new LPTrackerSDKException('Id is required'); |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
return true; |
105
|
|
|
} |
106
|
|
|
} |