格式化时间

This commit is contained in:
2025-03-20 09:30:04 +08:00
parent c60228d72b
commit 7fb921dc9f
2 changed files with 14 additions and 1 deletions
+12
View File
@@ -5,6 +5,8 @@ namespace app\model;
use app\util\Util;
use config\constants\Constants;
use DateTimeInterface;
use Illuminate\Support\Carbon;
use support\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@@ -47,6 +49,16 @@ class Customer extends Model
// 'created_at' => 'timestamp', // 指定序列化格式
];
/**
* 重新格式化时间
* @param DateTimeInterface $date
* @return string
*/
protected function serializeDate(DateTimeInterface $date): string
{
return $date->format(Carbon::parse($date)->toDateTimeString());
}
public static function getCustomer($customer)
{
$customer['grade_txt'] = Constants::GRADE[$customer['grade']];