mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-28 10:53:40 +03:00
Touch the new timestamp fields on insert/update.
This commit is contained in:
parent
2c203ae1aa
commit
ccc503e618
12 changed files with 53 additions and 3 deletions
|
@ -196,6 +196,9 @@ class Admins_model extends EA_Model {
|
|||
$settings = $admin['settings'];
|
||||
unset($admin['settings']);
|
||||
|
||||
$admin['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$admin['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->insert('users', $admin))
|
||||
{
|
||||
throw new RuntimeException('Could not insert admin.');
|
||||
|
@ -237,6 +240,8 @@ class Admins_model extends EA_Model {
|
|||
$settings['password'] = hash_password($existing_settings['salt'], $settings['password']);
|
||||
}
|
||||
|
||||
$admin['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('users', $admin, ['id' => $admin['id']]))
|
||||
{
|
||||
throw new RuntimeException('Could not update admin.');
|
||||
|
|
|
@ -175,6 +175,8 @@ class Appointments_model extends EA_Model {
|
|||
protected function insert(array $appointment): int
|
||||
{
|
||||
$appointment['book_datetime'] = date('Y-m-d H:i:s');
|
||||
$appointment['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$appointment['update_datetime'] = date('Y-m-d H:i:s');
|
||||
$appointment['hash'] = random_string('alnum', 12);
|
||||
|
||||
if ( ! $this->db->insert('appointments', $appointment))
|
||||
|
@ -196,6 +198,8 @@ class Appointments_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $appointment): int
|
||||
{
|
||||
$appointment['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('appointments', $appointment, ['id' => $appointment['id']]))
|
||||
{
|
||||
throw new RuntimeException('Could not update appointment record.');
|
||||
|
|
|
@ -98,6 +98,9 @@ class Categories_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $category): int
|
||||
{
|
||||
$category['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$category['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->insert('categories', $category))
|
||||
{
|
||||
throw new RuntimeException('Could not insert category.');
|
||||
|
@ -117,6 +120,8 @@ class Categories_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $category): int
|
||||
{
|
||||
$category['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('categories', $category, ['id' => $category['id']]))
|
||||
{
|
||||
throw new RuntimeException('Could not update service categories.');
|
||||
|
|
|
@ -82,8 +82,7 @@ class Consents_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $consent): int
|
||||
{
|
||||
$consent['created'] = date('Y-m-d H:i:s');
|
||||
$consent['modified'] = date('Y-m-d H:i:s');
|
||||
$consent['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->insert('consents', $consent))
|
||||
{
|
||||
|
@ -104,7 +103,7 @@ class Consents_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $consent): int
|
||||
{
|
||||
$consent['modified'] = date('Y-m-d H:i:s');
|
||||
$consent['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('consents', $consent, ['id' => $consent['id']]))
|
||||
{
|
||||
|
|
|
@ -157,6 +157,8 @@ class Customers_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $customer): int
|
||||
{
|
||||
$customer['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$customer['update_datetime'] = date('Y-m-d H:i:s');
|
||||
$customer['id_roles'] = $this->get_customer_role_id();
|
||||
|
||||
if ( ! $this->db->insert('users', $customer))
|
||||
|
@ -178,6 +180,8 @@ class Customers_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $customer): int
|
||||
{
|
||||
$customer['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('users', $customer, ['id' => $customer['id']]))
|
||||
{
|
||||
throw new RuntimeException('Could not update customer.');
|
||||
|
|
|
@ -206,6 +206,8 @@ class Providers_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $provider): int
|
||||
{
|
||||
$provider['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$provider['update_datetime'] = date('Y-m-d H:i:s');
|
||||
$provider['id_roles'] = $this->get_provider_role_id();
|
||||
|
||||
$service_ids = $provider['services'];
|
||||
|
@ -240,6 +242,8 @@ class Providers_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $provider): int
|
||||
{
|
||||
$provider['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
$service_ids = $provider['services'];
|
||||
unset($provider['services']);
|
||||
|
||||
|
|
|
@ -96,6 +96,9 @@ class Roles_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $role): int
|
||||
{
|
||||
$role['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$role['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->insert('roles', $role))
|
||||
{
|
||||
throw new RuntimeException('Could not insert role.');
|
||||
|
@ -115,6 +118,8 @@ class Roles_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $role): int
|
||||
{
|
||||
$role['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('roles', $role, ['id' => $role['id']]))
|
||||
{
|
||||
throw new RuntimeException('Could not update role.');
|
||||
|
|
|
@ -204,6 +204,9 @@ class Secretaries_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $secretary): int
|
||||
{
|
||||
$secretary['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$secretary['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
$secretary['id_roles'] = $this->get_secretary_role_id();
|
||||
|
||||
$providers = $secretary['providers'] ?? [];
|
||||
|
@ -239,6 +242,8 @@ class Secretaries_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $secretary): int
|
||||
{
|
||||
$secretary['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
$provider_ids = $secretary['providers'] ?? [];
|
||||
unset($secretary['providers']);
|
||||
|
||||
|
|
|
@ -154,6 +154,9 @@ class Services_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $service): int
|
||||
{
|
||||
$service['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$service['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->insert('services', $service))
|
||||
{
|
||||
throw new RuntimeException('Could not insert service.');
|
||||
|
@ -173,6 +176,8 @@ class Services_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $service): int
|
||||
{
|
||||
$service['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('services', $service, ['id' => $service['id']]))
|
||||
{
|
||||
throw new RuntimeException('Could not update service.');
|
||||
|
|
|
@ -97,6 +97,9 @@ class Settings_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $setting): int
|
||||
{
|
||||
$setting['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$setting['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->insert('settings', $setting))
|
||||
{
|
||||
throw new RuntimeException('Could not insert setting.');
|
||||
|
@ -116,6 +119,8 @@ class Settings_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $setting): int
|
||||
{
|
||||
$setting['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('settings', $setting, ['id' => $setting['id']]))
|
||||
{
|
||||
throw new RuntimeException('Could not update setting.');
|
||||
|
|
|
@ -129,6 +129,8 @@ class Unavailabilities_model extends EA_Model {
|
|||
protected function insert(array $unavailability): int
|
||||
{
|
||||
$unavailability['book_datetime'] = date('Y-m-d H:i:s');
|
||||
$unavailability['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$unavailability['update_datetime'] = date('Y-m-d H:i:s');
|
||||
$unavailability['hash'] = random_string('alnum', 12);
|
||||
$unavailability['is_unavailability'] = TRUE;
|
||||
|
||||
|
@ -151,6 +153,8 @@ class Unavailabilities_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $unavailability): int
|
||||
{
|
||||
$unavailability['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
if ( ! $this->db->update('appointments', $unavailability, ['id' => $unavailability['id']]))
|
||||
{
|
||||
throw new RuntimeException('Could not update unavailability record.');
|
||||
|
|
|
@ -113,6 +113,9 @@ class Users_model extends EA_Model {
|
|||
*/
|
||||
protected function insert(array $user): int
|
||||
{
|
||||
$user['create_datetime'] = date('Y-m-d H:i:s');
|
||||
$user['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
$settings = $user['settings'];
|
||||
unset($user['settings']);
|
||||
|
||||
|
@ -141,6 +144,8 @@ class Users_model extends EA_Model {
|
|||
*/
|
||||
protected function update(array $user): int
|
||||
{
|
||||
$user['update_datetime'] = date('Y-m-d H:i:s');
|
||||
|
||||
$settings = $user['settings'];
|
||||
unset($user['settings']);
|
||||
|
||||
|
|
Loading…
Reference in a new issue