This commit is contained in:
2025-04-11 11:32:41 +08:00
parent f9175f7dd4
commit 88dc849bd5
8 changed files with 435 additions and 11 deletions
+57
View File
@@ -0,0 +1,57 @@
<?php
namespace app\model;
use DateTimeInterface;
use Illuminate\Support\Carbon;
use support\Model;
class RequestTracks extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'request_tracks';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
//设置黑名单
protected $guarded = ['id','created_at'];
// 指定日期字段存储格式为时间戳
protected $dateFormat = 'U';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
protected $casts = [
'created_at' => 'datetime:Y-m-d H:i:s', // 指定序列化格式
];
/**
* 重新格式化时间
* @param DateTimeInterface $date
* @return string
*/
protected function serializeDate(DateTimeInterface $date): string
{
return $date->format(Carbon::parse($date)->toDateTimeString());
}
// 禁用 updated_at 的自动更新
public function setUpdatedAt($value)
{
return $this; // 不做任何操作
}
}