From 74e062e6bb4a9fe8b616f06ac54fef1d0db253d2 Mon Sep 17 00:00:00 2001 From: Nikita Kiselev Date: Sun, 30 Nov 2025 11:44:37 +0300 Subject: [PATCH] refactor: use Carbon for dates --- .../oc_telegram_shop/src/Models/TelegramCustomer.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) mode change 100644 => 100755 module/oc_telegram_shop/upload/oc_telegram_shop/src/Models/TelegramCustomer.php diff --git a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Models/TelegramCustomer.php b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Models/TelegramCustomer.php old mode 100644 new mode 100755 index 974c70f..a993513 --- a/module/oc_telegram_shop/upload/oc_telegram_shop/src/Models/TelegramCustomer.php +++ b/module/oc_telegram_shop/upload/oc_telegram_shop/src/Models/TelegramCustomer.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace App\Models; +use Carbon\Carbon; use Openguru\OpenCartFramework\QueryBuilder\Builder; use Openguru\OpenCartFramework\QueryBuilder\Connections\ConnectionInterface; use RuntimeException; @@ -78,8 +79,8 @@ class TelegramCustomer */ public function create(array $data): int { - $data['created_at'] = date('Y-m-d H:i:s'); - $data['updated_at'] = date('Y-m-d H:i:s'); + $data['created_at'] = Carbon::now()->toDateTimeString(); + $data['updated_at'] = Carbon::now()->toDateTimeString(); $success = $this->database->insert(self::TABLE_NAME, $data); @@ -101,7 +102,7 @@ class TelegramCustomer */ public function updateByTelegramUserId(int $telegramUserId, array $data): bool { - $data['updated_at'] = date('Y-m-d H:i:s'); + $data['updated_at'] = Carbon::now()->toDateTimeString(); return $this->builder->newQuery() ->where('telegram_user_id', '=', $telegramUserId) @@ -117,14 +118,15 @@ class TelegramCustomer public function updateLastSeen(int $telegramUserId): bool { return $this->updateByTelegramUserId($telegramUserId, [ - 'last_seen_at' => date('Y-m-d H:i:s'), + 'last_seen_at' => Carbon::now()->toDateTimeString(), ]); } public function increase(int $id, string $field): bool { + $now = Carbon::now()->toDateTimeString(); $table = self::TABLE_NAME; - $sql = "UPDATE `$table` SET `$field` = `$field` + 1 WHERE id = ?"; + $sql = "UPDATE `$table` SET `$field` = `$field` + 1, updated_at = '$now' WHERE id = ?"; return $this->database->statement($sql, [$id]); }