# |
Jun 7th 2019, 04:44 |
liaogz82 |
or should it be `Asia/Malaysia`? |
# |
Jun 7th 2019, 04:43 |
liaogz82 |
can I set it as `GMT+8`?? |
# |
Jun 7th 2019, 04:38 |
niel45 |
defaults to UTC IIRC |
# |
Jun 7th 2019, 04:38 |
niel45 |
default timezone can be set in your app.php |
# |
Jun 7th 2019, 04:36 |
liaogz82 |
ok how do you set the timezone in cakephp? |
# |
Jun 7th 2019, 04:30 |
conehead |
And just make sure you get no errors with the timezone |
# |
Jun 7th 2019, 04:29 |
conehead |
And save it as DateTime |
# |
Jun 7th 2019, 04:29 |
conehead |
I am not an expert, but right now, in ```beforeMarshal()``` I would check if it is a valid timestamp and convert it to DateTime |
# |
Jun 7th 2019, 04:28 |
liaogz82 |
`"date_of_birth":1555862400000` |
# |
Jun 7th 2019, 04:28 |
liaogz82 |
well customer requirement is the data send over is in miliseconds |
# |
Jun 7th 2019, 04:27 |
conehead |
Or an int? |
# |
Jun 7th 2019, 04:27 |
conehead |
Why would you? As a string? |
# |
Jun 7th 2019, 04:27 |
liaogz82 |
check with you guys, how do you save date time in milliseconds in cakephp? |
# |
Jun 7th 2019, 04:21 |
liaogz82 |
oh god no! I go and add it in now |
# |
Jun 7th 2019, 04:17 |
conehead |
Did you add the `associated` key? ``` $entity = $articles->newEntity($this->request->getData(), [ 'associated' => [ 'Tags', 'Comments' => ['associated' => ['Users']] ] ]); ``` |
# |
Jun 7th 2019, 04:13 |
liaogz82 |
this part, should I change `worker_section_type` to `WorkerSectionType`?? |
# |
Jun 7th 2019, 04:12 |
slackebot |
"worker_overtime": [{ "code":"5S", "description":"AUDIT 5S", "amount":"1000", "remark":"PAJAK(5S)" }] } ``` |
# |
Jun 7th 2019, 04:12 |
liaogz82 |
``` "worker_section_type":{ "section_id":1, "worker_gaji": [{ "code":"PM_3U", "description":"MI 3 UDANG", "amount":"20", "remark":"PAJAK(1 BAG)" }], "worker_tambahan": [{ "code":"FULL_2U", "description":"F/HARIAN >100 BAGS 2 UDG", "amount":"10", "remark":"PAJAK(BAG)" }], |
# |
Jun 7th 2019, 04:11 |
liaogz82 |
but it does have many to many relationships |
# |
Jun 7th 2019, 04:11 |
liaogz82 |
no I just save one, not many |
# |
Jun 7th 2019, 04:10 |
conehead |
Guess you are looking for `saveMany()` https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-multiple-entities |
# |
Jun 7th 2019, 03:54 |
kgb.acct.personal |
https://book.cakephp.org/3.0/en/orm/saving-data.html#saving-with-associations |
# |
Jun 7th 2019, 03:53 |
kgb.acct.personal |
Too bad. Looks like saveAll is not in Cake3 anymore. You can use just save() or saveMany() |
# |
Jun 7th 2019, 03:47 |
liaogz82 |
sorry I misinterpret what you say |
# |
Jun 7th 2019, 03:47 |
liaogz82 |
this is it |
# |
Jun 7th 2019, 03:47 |
liaogz82 |
``` public function add() { $worker = $this->Workers->newEntity(); $success = false; if ($this->request->is('post')) { $worker = $this->Workers->patchEntity($worker, $this->request->getData()); if ($this->Workers->saveAll($worker)) { $success = true; } $this->set([ 'success' => $success, '_serialize' => ['success'] ]); } } ``` |
# |
Jun 7th 2019, 03:39 |
kgb.acct.personal |
You're supposed to use your model table to call saveAll() |
# |
Jun 7th 2019, 03:38 |
kgb.acct.personal |
I mean the statement where you call saveAll() |
# |
Jun 7th 2019, 03:36 |
liaogz82 |
this is the data i want to save |
# |
Jun 7th 2019, 03:36 |
slackebot |
"phone_number":"019-8998571" } ``` |
# |
Jun 7th 2019, 03:36 |
slackebot |
"worker_overtime": [{ "code":"5S", "description":"AUDIT 5S", "amount":"1000", "remark":"PAJAK(5S)" }] }, "date_of_birth":1555862400000, "date_join":1555862400000, "ic_number":"831108-12-6180", "epf_number":"21783801", "income_tax_number":"N/A", "socso_number":"831108126180", "document":"NI", "citizen_id":1, "race_id":1, "religion_id":1, "bank_number":"4-6944323-23", "is_vip":0, "date_resign":1555862400000, |
# |
Jun 7th 2019, 03:36 |
liaogz82 |
``` { "name":"JIAH BINTI NUNO", "location_id": 1, "job_description":"PEKERJA AM(PACKING MEE)", "gender":"F", "payment_type":"D", "worker_section_type":{ "section_id":1, "worker_gaji": [{ "code":"PM_3U", "description":"MI 3 UDANG", "amount":"20", "remark":"PAJAK(1 BAG)" }], "worker_tambahan": [{ "code":"FULL_2U", "description":"F/HARIAN >100 BAGS 2 UDG", "amount":"10", "remark":"PAJAK(BAG)" }], |
# |
Jun 7th 2019, 03:35 |
liaogz82 |
this is the api call |
# |
Jun 7th 2019, 03:35 |
liaogz82 |
``` { "message": "Unknown method \"saveAll\"", "url": "/workers/add.json", "code": 500, "file": "/var/www/html/vendor/cakephp/cakephp/src/ORM/Table.php", "line": 2512 } ``` |
# |
Jun 7th 2019, 03:31 |
kgb.acct.personal |
Can you post the whole syntax? |
# |
Jun 7th 2019, 03:28 |
liaogz82 |
where could this gone wrong? |
# |
Jun 7th 2019, 03:28 |
liaogz82 |
Hi guys I am using cakephp 3.6 and it keep giving this error `Unknown method "saveAll"` |
# |
Jun 6th 2019, 20:22 |
ckjksl |
but no worries, i'll figure it out. Thanks for the ideas! |
# |
Jun 6th 2019, 20:22 |
ckjksl |
the problem with randomized ID is that they need to be associated to the tag. |
# |
Jun 6th 2019, 20:21 |
jeremyharris |
many ways to solve it ¯\_(ツ)_/¯ |
# |
Jun 6th 2019, 20:20 |
ricksaccous |
oh well |