Laravel 8.69 released with "Str::mask()" method which masks a portion of string with a repeated character
1class PasswordResetLinkController extends Controller 2{ 3 public function sendResetLinkResponse(Request $request) 4 { 5 $userEmail = User::where('email', $request->email)->value('email'); // username@domain.com 6 7 $maskedEmail = Str::mask($userEmail, '*', 4); // user*************** 8 9 // If needed, you provide a negative number as the third argument to the mask method,10 // which will instruct the method to begin masking at the given distance from the end of the string11 12 $maskedEmail = Str::mask($userEmail, '*', -16, 6); // use******domain.com13 }14}
Tip given by @Teacoders