abdulmajidcse/laravel-code-mask

This is a simple Laravel package that help you to manipulate your data.

v1.0.1 2024-06-30 17:49 UTC

This package is auto-updated.

Last update: 2025-04-29 01:29:31 UTC


README

This is a simple Laravel package that help you to manipulate your data.

Requirements

  • PHP >=7.4 | >=8.0
  • Laravel >= 8.0 | >= 9.0 | >= 10.0 | >= 11.0

Installation

composer require abdulmajidcse/laravel-code-mask

Optional: The service provider will automatically get registered. Or you may manually add the service provider.

  • For Laravel v10 or lower (In your config/app.php file).
'providers' => [
    // ...
    Abdulmajidcse\LaravelCodeMask\LaravelCodeMaskServiceProvider::class,
];
  • For Laravel v11 or upper (In your bootstrap/providers.php file).
return [
    // ...
    Abdulmajidcse\LaravelCodeMask\LaravelCodeMaskServiceProvider::class,
];

Optional: The aliases will automatically get registered. Or you may manually add the aliases in your config/app.php file.

'aliases' => Facade::defaultAliases()->merge([
    // ...
    'CodeMaskFacade' => Abdulmajidcse\LaravelCodeMask\Facades\CodeMaskFacade::class,
])->toArray(),

Usage

You'll see code example so that you can guess where you have to use it.

Hide String

Sometimes, you need to hide phone, email or any other text with your special letter like 12****90. For this type of tasks, you can follow below code sample.

use Abdulmajidcse\LaravelCodeMask\Facades\CodeMaskFacade;

$phoneNumber = "1234567890";
$hidePhoneNumber = CodeMaskFacade::hideString($phoneNumber, 2, 2);

echo $hidePhoneNumber; // output: 12******90

Generate ID

Suppose, you have to generate an ID or any other string based ID with a special format. To do this, you can follow below code sample.

use Abdulmajidcse\LaravelCodeMask\Facades\CodeMaskFacade;

$id = CodeMaskFacade::generateId(123, 10, 0, '2701');

echo $id; // output: 27010000000123

Money Format

Suppose, you have a number that need to format with your country money format. To do this, you can follow below code sample.

use Abdulmajidcse\LaravelCodeMask\Facades\CodeMaskFacade;

$moneyWithLeftCurrency = CodeMaskFacade::moneyFormat(100000000.556, 'TK');
echo $moneyWithLeftCurrency; // output: TK 10,00,00,000.56

$moneyWithRightCurrency = CodeMaskFacade::moneyFormat(100000000.556, '', 'BDT');
echo $moneyWithRightCurrency; // output: 10,00,00,000.56 BDT