Skip to content

Commit

Permalink
feat: 统一 Model 的时间
Browse files Browse the repository at this point in the history
  • Loading branch information
supgeek-rod committed Jun 25, 2024
1 parent 4083eef commit 8172776
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/Models/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ class Model extends EloquentModel
public static $statuses = [
];

/**
* 格式化时间
*/
protected function serializeDate(\DateTimeInterface $date)
{
if (version_compare(app()->version(), '7.0.0') < 0) {
return parent::serializeDate($date);
}

return $date->format(Carbon::DEFAULT_TO_STRING_FORMAT);
}

/**
* Relation User
*/
Expand Down

0 comments on commit 8172776

Please sign in to comment.