feat: 隐藏客户名
This commit is contained in:
parent
62df6dda50
commit
c6b986f06f
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user