clqms-be/app/Models/BaseModel.php

30 lines
748 B
PHP
Raw Normal View History

2025-10-13 12:28:09 +07:00
<?php
namespace App\Models;
use CodeIgniter\Model;
2025-10-14 18:53:06 +07:00
class BaseModel extends Model {
2025-10-13 12:28:09 +07:00
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
protected function normalizeDatesToUTC(array $data) {
helper('utc');
if (isset($data['data'])) {
$data['data'] = convert_array_to_utc($data['data']);
}
return $data;
}
protected function convertDatesToUTCISO(array $data) {
helper('utc');
if (isset($data['data'])) {
$data['data'] = convert_array_to_utc_iso($data['data']);
}
return $data;
}
}