|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Cortex\Contacts\Models; |
|
6
|
|
|
|
|
7
|
|
|
use Rinvex\Tags\Traits\Taggable; |
|
8
|
|
|
use Rinvex\Tenants\Traits\Tenantable; |
|
9
|
|
|
use Cortex\Foundation\Traits\Auditable; |
|
10
|
|
|
use Rinvex\Support\Traits\HashidsTrait; |
|
11
|
|
|
use Spatie\Activitylog\Traits\LogsActivity; |
|
12
|
|
|
use Rinvex\Support\Traits\HasSocialAttributes; |
|
13
|
|
|
use Rinvex\Contacts\Models\Contact as BaseContact; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Cortex\Contacts\Models\Contact. |
|
17
|
|
|
* |
|
18
|
|
|
* @property int $id |
|
19
|
|
|
* @property int $entity_id |
|
20
|
|
|
* @property string $entity_type |
|
21
|
|
|
* @property string $given_name |
|
22
|
|
|
* @property string $family_name |
|
23
|
|
|
* @property string $full_name |
|
24
|
|
|
* @property string $title |
|
25
|
|
|
* @property string $organization |
|
26
|
|
|
* @property string $email |
|
27
|
|
|
* @property string $phone |
|
28
|
|
|
* @property string $fax |
|
29
|
|
|
* @property string $country_code |
|
30
|
|
|
* @property string $language_code |
|
31
|
|
|
* @property string $birthday |
|
32
|
|
|
* @property string $gender |
|
33
|
|
|
* @property array $social |
|
34
|
|
|
* @property string $national_id_type |
|
35
|
|
|
* @property string $national_id |
|
36
|
|
|
* @property string $source |
|
37
|
|
|
* @property string $method |
|
38
|
|
|
* @property string $notes |
|
39
|
|
|
* @property \Carbon\Carbon|null $created_at |
|
40
|
|
|
* @property \Carbon\Carbon|null $updated_at |
|
41
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Cortex\Foundation\Models\Log[] $activity |
|
42
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Cortex\Contacts\Models\Contact[] $backRelatives |
|
43
|
|
|
* @property-read \Illuminate\Database\Eloquent\Model|\Eloquent $entity |
|
44
|
|
|
* @property-read \Illuminate\Database\Eloquent\Collection|\Cortex\Contacts\Models\Contact[] $relatives |
|
45
|
|
|
* @property \Illuminate\Database\Eloquent\Collection|\Cortex\Tenants\Models\Tenant[] $tenants |
|
46
|
|
|
* |
|
47
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact country($countryCode) |
|
48
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact language($languageCode) |
|
49
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact method($method) |
|
50
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact source($source) |
|
51
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereBirthday($value) |
|
52
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereCountryCode($value) |
|
53
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereCreatedAt($value) |
|
54
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereEmail($value) |
|
55
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereEntityId($value) |
|
56
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereEntityType($value) |
|
57
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereFax($value) |
|
58
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereFamilyName($value) |
|
59
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereGivenName($value) |
|
60
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereGender($value) |
|
61
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereId($value) |
|
62
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereLanguageCode($value) |
|
63
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereNationalId($value) |
|
64
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereNationalIdType($value) |
|
65
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereMethod($value) |
|
66
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereNotes($value) |
|
67
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereOrganization($value) |
|
68
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact wherePhone($value) |
|
69
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereSocial($value) |
|
70
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereSource($value) |
|
71
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereTitle($value) |
|
72
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Rinvex\Contacts\Models\Contact whereUpdatedAt($value) |
|
73
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Contacts\Models\Contact withAllTenants($tenants, $group = null) |
|
|
|
|
|
|
74
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Contacts\Models\Contact withAnyTenants($tenants, $group = null) |
|
|
|
|
|
|
75
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Contacts\Models\Contact withTenants($tenants, $group = null) |
|
|
|
|
|
|
76
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Contacts\Models\Contact withoutAnyTenants() |
|
77
|
|
|
* @method static \Illuminate\Database\Eloquent\Builder|\Cortex\Contacts\Models\Contact withoutTenants($tenants, $group = null) |
|
|
|
|
|
|
78
|
|
|
* @mixin \Eloquent |
|
79
|
|
|
*/ |
|
80
|
|
|
class Contact extends BaseContact |
|
81
|
|
|
{ |
|
82
|
|
|
use Taggable; |
|
83
|
|
|
use Auditable; |
|
84
|
|
|
use Tenantable; |
|
85
|
|
|
use HashidsTrait; |
|
86
|
|
|
use LogsActivity; |
|
87
|
|
|
use HasSocialAttributes; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* {@inheritdoc} |
|
91
|
|
|
*/ |
|
92
|
|
|
protected $fillable = [ |
|
93
|
|
|
'entity_id', |
|
94
|
|
|
'entity_type', |
|
95
|
|
|
'source', |
|
96
|
|
|
'method', |
|
97
|
|
|
'given_name', |
|
98
|
|
|
'family_name', |
|
99
|
|
|
'title', |
|
100
|
|
|
'organization', |
|
101
|
|
|
'email', |
|
102
|
|
|
'phone', |
|
103
|
|
|
'fax', |
|
104
|
|
|
'country_code', |
|
105
|
|
|
'language_code', |
|
106
|
|
|
'birthday', |
|
107
|
|
|
'gender', |
|
108
|
|
|
'social', |
|
109
|
|
|
'national_id_type', |
|
110
|
|
|
'national_id', |
|
111
|
|
|
'source', |
|
112
|
|
|
'method', |
|
113
|
|
|
'notes', |
|
114
|
|
|
'tags', |
|
115
|
|
|
]; |
|
116
|
|
|
|
|
117
|
|
|
/** |
|
118
|
|
|
* {@inheritdoc} |
|
119
|
|
|
*/ |
|
120
|
|
|
protected $casts = [ |
|
121
|
|
|
'entity_id' => 'integer', |
|
122
|
|
|
'entity_type' => 'string', |
|
123
|
|
|
'given_name' => 'string', |
|
124
|
|
|
'family_name' => 'string', |
|
125
|
|
|
'title' => 'string', |
|
126
|
|
|
'organization' => 'string', |
|
127
|
|
|
'email' => 'string', |
|
128
|
|
|
'phone' => 'string', |
|
129
|
|
|
'fax' => 'string', |
|
130
|
|
|
'country_code' => 'string', |
|
131
|
|
|
'language_code' => 'string', |
|
132
|
|
|
'birthday' => 'string', |
|
133
|
|
|
'gender' => 'string', |
|
134
|
|
|
'social' => 'array', |
|
135
|
|
|
'national_id_type' => 'string', |
|
136
|
|
|
'national_id' => 'string', |
|
137
|
|
|
'source' => 'string', |
|
138
|
|
|
'method' => 'string', |
|
139
|
|
|
'notes' => 'string', |
|
140
|
|
|
'deleted_at' => 'datetime', |
|
141
|
|
|
]; |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* The default rules that the model will validate against. |
|
145
|
|
|
* |
|
146
|
|
|
* @var array |
|
147
|
|
|
*/ |
|
148
|
|
|
protected $rules = [ |
|
149
|
|
|
'entity_id' => 'required|integer', |
|
150
|
|
|
'entity_type' => 'required|string|max:150', |
|
151
|
|
|
'given_name' => 'required|string|max:150', |
|
152
|
|
|
'family_name' => 'nullable|string|max:150', |
|
153
|
|
|
'title' => 'nullable|string|max:150', |
|
154
|
|
|
'organization' => 'nullable|string|max:150', |
|
155
|
|
|
'email' => 'required|email|min:3|max:150', |
|
156
|
|
|
'phone' => 'nullable|phone:AUTO', |
|
157
|
|
|
'fax' => 'nullable|string|max:150', |
|
158
|
|
|
'country_code' => 'nullable|alpha|size:2|country', |
|
159
|
|
|
'language_code' => 'nullable|alpha|size:2|language', |
|
160
|
|
|
'birthday' => 'nullable|date_format:Y-m-d', |
|
161
|
|
|
'gender' => 'nullable|in:male,female', |
|
162
|
|
|
'social' => 'nullable', |
|
163
|
|
|
'national_id_type' => 'nullable|in:identification,passport,other', |
|
164
|
|
|
'national_id' => 'nullable|string|max:150', |
|
165
|
|
|
'source' => 'nullable|string|max:150', |
|
166
|
|
|
'method' => 'nullable|string|max:150', |
|
167
|
|
|
'notes' => 'nullable|string|max:10000', |
|
168
|
|
|
'tags' => 'nullable|array', |
|
169
|
|
|
]; |
|
170
|
|
|
|
|
171
|
|
|
/** |
|
172
|
|
|
* Indicates whether to log only dirty attributes or all. |
|
173
|
|
|
* |
|
174
|
|
|
* @var bool |
|
175
|
|
|
*/ |
|
176
|
|
|
protected static $logOnlyDirty = true; |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* The attributes that are logged on change. |
|
180
|
|
|
* |
|
181
|
|
|
* @var array |
|
182
|
|
|
*/ |
|
183
|
|
|
protected static $logFillable = true; |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* The attributes that are ignored on change. |
|
187
|
|
|
* |
|
188
|
|
|
* @var array |
|
189
|
|
|
*/ |
|
190
|
|
|
protected static $ignoreChangedAttributes = [ |
|
|
|
|
|
|
191
|
|
|
'created_at', |
|
192
|
|
|
'updated_at', |
|
193
|
|
|
'deleted_at', |
|
194
|
|
|
]; |
|
195
|
|
|
} |
|
196
|
|
|
|
Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.