'int', 'openid' => 'string', 'unionid' => 'string', 'sessionKey' => 'string', 'nickname' => 'string', 'avatar' => 'string', 'phone' => 'string', 'ext_uid' => 'string', 'third_party_phone' => 'string', 'third_party_tid' => 'string', 'gender' => 'int', 'country' => 'string', 'province' => 'string', 'city' => 'string', 'birthday' => 'string', 'status' => 'int', 'lastLoginAt' => 'int', 'lastLoginIp' => 'string', 'enterpriseId' => 'int', 'createdAt' => 'int', 'updatedAt' => 'int', ]; protected $autoWriteTimestamp = 'int'; protected $createTime = 'createdAt'; protected $updateTime = 'updatedAt'; protected $hidden = ['sessionKey', 'openid']; protected $type = [ 'lastLoginAt' => 'integer', 'createdAt' => 'integer', 'updatedAt' => 'integer', ]; /** * 返回给前端的用户信息(不包含敏感字段) */ public function toApiArray(): array { $row = $this->toArray(); unset($row['sessionKey'], $row['openid']); $row['avatarUrl'] = $row['avatar'] ?? ''; return $row; } }