1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* CakePHPify : CakePHP Plugin for Shopify API Authentication |
4
|
|
|
* Copyright (c) Multidimension.al (http://multidimension.al) |
5
|
|
|
* Github : https://github.com/multidimension-al/cakephpify |
6
|
|
|
* |
7
|
|
|
* Licensed under The MIT License |
8
|
|
|
* For full copyright and license information, please see the LICENSE file |
9
|
|
|
* Redistributions of files must retain the above copyright notice. |
10
|
|
|
* |
11
|
|
|
* @copyright (c) Multidimension.al (http://multidimension.al) |
12
|
|
|
* @link https://github.com/multidimension-al/cakephpify CakePHPify Github |
13
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT License |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Multidimensional\Shopify\Model\Table; |
17
|
|
|
|
18
|
|
|
use Cake\ORM\Query; |
19
|
|
|
use Cake\ORM\RulesChecker; |
20
|
|
|
use Cake\ORM\Table; |
21
|
|
|
use Cake\Validation\Validator; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Shops Model |
25
|
|
|
* |
26
|
|
|
* @method \App\Model\Entity\Shop get($primaryKey, $options = []) |
27
|
|
|
* @method \App\Model\Entity\Shop newEntity($data = null, array $options = []) |
28
|
|
|
* @method \App\Model\Entity\Shop[] newEntities(array $data, array $options = []) |
29
|
|
|
* @method \App\Model\Entity\Shop|bool save(\Cake\Datasource\EntityInterface $entity, $options = []) |
30
|
|
|
* @method \App\Model\Entity\Shop patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = []) |
31
|
|
|
* @method \App\Model\Entity\Shop[] patchEntities($entities, array $data, array $options = []) |
32
|
|
|
* @method \App\Model\Entity\Shop findOrCreate($search, callable $callback = null) |
33
|
|
|
*/ |
34
|
|
|
class ShopsTable extends Table { |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Initialize method |
38
|
|
|
* |
39
|
|
|
* @param array $config The configuration for the Table. |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
30 |
|
public function initialize(array $config) { |
43
|
30 |
|
parent::initialize($config); |
44
|
|
|
|
45
|
|
|
//$this->table('shops'); |
46
|
30 |
|
$this->displayField('myshopify_domain'); |
47
|
|
|
//$this->primaryKey('id'); |
48
|
|
|
|
49
|
30 |
|
$this->hasMany('AccessTokens', [ |
50
|
|
|
'className' => 'Multidimensional/Shopify.AccessTokens' |
51
|
30 |
|
]); |
52
|
|
|
|
53
|
30 |
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Default validation rules. |
57
|
|
|
* |
58
|
|
|
* @param \Cake\Validation\Validator $validator Validator instance. |
59
|
|
|
* @return \Cake\Validation\Validator |
60
|
|
|
*/ |
61
|
|
|
public function validationDefault(Validator $validator) { |
62
|
|
|
$validator |
63
|
|
|
->integer('id') |
64
|
|
|
->allowEmpty('id', 'create'); |
65
|
|
|
|
66
|
|
|
$validator |
67
|
|
|
->requirePresence('domain', 'create') |
68
|
|
|
->notEmpty('domain'); |
69
|
|
|
|
70
|
|
|
$validator |
71
|
|
|
->requirePresence('name', 'create') |
72
|
|
|
->notEmpty('name'); |
73
|
|
|
|
74
|
|
|
$validator |
75
|
|
|
->email('email') |
76
|
|
|
->requirePresence('email', 'create') |
77
|
|
|
->notEmpty('email'); |
78
|
|
|
|
79
|
|
|
$validator |
80
|
|
|
->requirePresence('shop_owner', 'create') |
81
|
|
|
->notEmpty('shop_owner'); |
82
|
|
|
|
83
|
|
|
$validator |
84
|
|
|
->requirePresence('address1', 'create') |
85
|
|
|
->notEmpty('address1'); |
86
|
|
|
|
87
|
|
|
$validator |
88
|
|
|
->requirePresence('address2', 'create') |
89
|
|
|
->notEmpty('address2'); |
90
|
|
|
|
91
|
|
|
$validator |
92
|
|
|
->requirePresence('city', 'create') |
93
|
|
|
->notEmpty('city'); |
94
|
|
|
|
95
|
|
|
$validator |
96
|
|
|
->requirePresence('province_code', 'create') |
97
|
|
|
->notEmpty('province_code'); |
98
|
|
|
|
99
|
|
|
$validator |
100
|
|
|
->requirePresence('province', 'create') |
101
|
|
|
->notEmpty('province'); |
102
|
|
|
|
103
|
|
|
$validator |
104
|
|
|
->requirePresence('zip', 'create') |
105
|
|
|
->notEmpty('zip'); |
106
|
|
|
|
107
|
|
|
$validator |
108
|
|
|
->requirePresence('country', 'create') |
109
|
|
|
->notEmpty('country'); |
110
|
|
|
|
111
|
|
|
$validator |
112
|
|
|
->requirePresence('country_code', 'create') |
113
|
|
|
->notEmpty('country_code'); |
114
|
|
|
|
115
|
|
|
$validator |
116
|
|
|
->requirePresence('country_name', 'create') |
117
|
|
|
->notEmpty('country_name'); |
118
|
|
|
|
119
|
|
|
$validator |
120
|
|
|
->allowEmpty('source'); |
121
|
|
|
|
122
|
|
|
$validator |
123
|
|
|
->requirePresence('phone', 'create') |
124
|
|
|
->notEmpty('phone'); |
125
|
|
|
|
126
|
|
|
$validator |
127
|
|
|
->dateTime('created_at') |
128
|
|
|
->requirePresence('created_at', 'create') |
129
|
|
|
->notEmpty('created_at'); |
130
|
|
|
|
131
|
|
|
$validator |
132
|
|
|
->dateTime('updated_at') |
133
|
|
|
->requirePresence('updated_at', 'create') |
134
|
|
|
->notEmpty('updated_at'); |
135
|
|
|
|
136
|
|
|
$validator |
137
|
|
|
->requirePresence('customer_email', 'create') |
138
|
|
|
->allowEmpty('customer_email'); |
139
|
|
|
|
140
|
|
|
$validator |
141
|
|
|
->decimal('latitude') |
142
|
|
|
->requirePresence('latitude', 'create') |
143
|
|
|
->notEmpty('latitude'); |
144
|
|
|
|
145
|
|
|
$validator |
146
|
|
|
->decimal('longitude') |
147
|
|
|
->requirePresence('longitude', 'create') |
148
|
|
|
->notEmpty('longitude'); |
149
|
|
|
|
150
|
|
|
$validator |
151
|
|
|
->requirePresence('primary_locale', 'create') |
152
|
|
|
->notEmpty('primary_locale'); |
153
|
|
|
|
154
|
|
|
$validator |
155
|
|
|
->requirePresence('currency', 'create') |
156
|
|
|
->notEmpty('currency'); |
157
|
|
|
|
158
|
|
|
$validator |
159
|
|
|
->requirePresence('iana_timezone', 'create') |
160
|
|
|
->notEmpty('iana_timezone'); |
161
|
|
|
|
162
|
|
|
$validator |
163
|
|
|
->requirePresence('money_format', 'create') |
164
|
|
|
->notEmpty('money_format'); |
165
|
|
|
|
166
|
|
|
$validator |
167
|
|
|
->requirePresence('money_with_currency_format', 'create') |
168
|
|
|
->notEmpty('money_with_currency_format'); |
169
|
|
|
|
170
|
|
|
$validator |
171
|
|
|
->boolean('taxes_included') |
172
|
|
|
->allowEmpty('taxes_included'); |
173
|
|
|
|
174
|
|
|
$validator |
175
|
|
|
->boolean('tax_shipping') |
176
|
|
|
->allowEmpty('tax_shipping'); |
177
|
|
|
|
178
|
|
|
$validator |
179
|
|
|
->boolean('county_taxes') |
180
|
|
|
->allowEmpty('county_taxes'); |
181
|
|
|
|
182
|
|
|
$validator |
183
|
|
|
->requirePresence('plan_display_name', 'create') |
184
|
|
|
->notEmpty('plan_display_name'); |
185
|
|
|
|
186
|
|
|
$validator |
187
|
|
|
->requirePresence('plan_name', 'create') |
188
|
|
|
->notEmpty('plan_name'); |
189
|
|
|
|
190
|
|
|
$validator |
191
|
|
|
->boolean('has_discounts') |
192
|
|
|
->allowEmpty('has_discounts'); |
193
|
|
|
|
194
|
|
|
$validator |
195
|
|
|
->boolean('has_gift_cards') |
196
|
|
|
->allowEmpty('has_gift_cards'); |
197
|
|
|
|
198
|
|
|
$validator |
199
|
|
|
->requirePresence('myshopify_domain', 'create') |
200
|
|
|
->notEmpty('myshopify_domain'); |
201
|
|
|
|
202
|
|
|
$validator |
203
|
|
|
->allowEmpty('google_apps_domain'); |
204
|
|
|
|
205
|
|
|
$validator |
206
|
|
|
->allowEmpty('google_apps_login_enabled'); |
207
|
|
|
|
208
|
|
|
$validator |
209
|
|
|
->requirePresence('money_in_emails_format', 'create') |
210
|
|
|
->notEmpty('money_in_emails_format'); |
211
|
|
|
|
212
|
|
|
$validator |
213
|
|
|
->requirePresence('money_with_currency_in_emails_format', 'create') |
214
|
|
|
->notEmpty('money_with_currency_in_emails_format'); |
215
|
|
|
|
216
|
|
|
$validator |
217
|
|
|
->boolean('eligible_for_payments') |
218
|
|
|
->allowEmpty('eligible_for_payments'); |
219
|
|
|
|
220
|
|
|
$validator |
221
|
|
|
->boolean('requires_extra_payments_agreement') |
222
|
|
|
->allowEmpty('requires_extra_payments_agreement'); |
223
|
|
|
|
224
|
|
|
$validator |
225
|
|
|
->boolean('password_enabled') |
226
|
|
|
->allowEmpty('password_enabled'); |
227
|
|
|
|
228
|
|
|
$validator |
229
|
|
|
->boolean('has_storefront') |
230
|
|
|
->allowEmpty('has_storefront'); |
231
|
|
|
|
232
|
|
|
$validator |
233
|
|
|
->boolean('eligible_for_card_reader_giveaway') |
234
|
|
|
->allowEmpty('eligible_for_card_reader_giveaway'); |
235
|
|
|
|
236
|
|
|
$validator |
237
|
|
|
->boolean('finances') |
238
|
|
|
->allowEmpty('finances'); |
239
|
|
|
|
240
|
|
|
$validator |
241
|
|
|
->boolean('setup_required') |
242
|
|
|
->allowEmpty('setup_required'); |
243
|
|
|
|
244
|
|
|
$validator |
245
|
|
|
->boolean('force_ssl') |
246
|
|
|
->allowEmpty('force_ssl'); |
247
|
|
|
|
248
|
|
|
return $validator; |
249
|
|
|
} |
250
|
|
|
|
251
|
|
|
/** |
252
|
|
|
* Returns a rules checker object that will be used for validating |
253
|
|
|
* application integrity. |
254
|
|
|
* |
255
|
|
|
* @param \Cake\ORM\RulesChecker $rules The rules object to be modified. |
256
|
|
|
* @return \Cake\ORM\RulesChecker |
257
|
|
|
*/ |
258
|
|
|
public function buildRules(RulesChecker $rules) { |
259
|
|
|
$rules->add($rules->isUnique(['email'])); |
260
|
|
|
|
261
|
|
|
return $rules; |
262
|
|
|
} |
263
|
|
|
} |
264
|
|
|
|