feat: 隐藏客户名

This commit is contained in:
苟川东 2025-05-07 20:13:24 +08:00
parent 62df6dda50
commit c6b986f06f
2 changed files with 24 additions and 0 deletions

View File

@ -525,3 +525,22 @@ if (!function_exists('dd')) {
}
}
if (!function_exists('maskExceptFirstChar')) {
/**
* 将字符串的首个字符保留,其余字符全部替换为 *
*/
function maskExceptFirstChar(string $str): string
{
$length = mb_strlen($str, 'UTF-8');
if ($length <= 1) {
return $str;
}
$firstChar = mb_substr($str, 0, 1, 'UTF-8');
$masked = str_repeat('*', $length - 1);
return $firstChar . $masked;
}
}

View File

@ -18,4 +18,9 @@ class Order extends Model
{
return $this->belongsTo(\app\admin\model\Area::class,'area_id', 'area_code');
}
public function getCustomerAttr(string $val)
{
return maskExceptFirstChar($val);
}
}