From 08a7a10392e91a774581f9fe66527f73eec0ab88 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 20 Aug 2025 15:24:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=A5=E5=8D=95=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/ticket/model/Ticket.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/app/ticket/model/Ticket.php b/app/ticket/model/Ticket.php index 41b3794..d1bbe9e 100644 --- a/app/ticket/model/Ticket.php +++ b/app/ticket/model/Ticket.php @@ -47,10 +47,27 @@ class Ticket extends Model * * @var bool */ - public $timestamps = true; + public $timestamps = false; protected $dateFormat = 'U'; + /** + * 在保存时手动设置时间戳 + */ + protected static function boot() + { + parent::boot(); + + static::creating(function ($model) { + $model->created_at = time(); + $model->updated_at = time(); + }); + + static::updating(function ($model) { + $model->updated_at = time(); + }); + } + /** * 指定哪些字段自动转换为 Carbon 实例 */