[更新] 微调

This commit is contained in:
2021-01-31 14:58:23 +08:00
parent abea4f86d5
commit 6e0d21ab06
3 changed files with 26 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Models;
use App\Models\Traits\HasAccount;
use App\Models\Traits\HasArea;
use DateTimeInterface;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Str;
@@ -65,6 +66,16 @@ class User extends Authenticatable
});
}
/**
* 为数组 / JSON 序列化准备日期。
* @param \DateTimeInterface $date
* @return string
*/
protected function serializeDate(DateTimeInterface $date)
{
return $date->format($this->dateFormat ?: 'Y-m-d H:i:s');
}
protected function getNicknameAttribute()
{
return $this->info ? $this->info->nickname : '';