creative_mazhar / bdt-currency-helper
A Laravel helper to format and convert Bangladeshi Taka (৳) with Bangla digits, lakh grouping, and number-to-words conversion.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Forks: 0
pkg:composer/creative_mazhar/bdt-currency-helper
Requires
- php: ^8.1
- illuminate/support: ^10.0 || ^11.0 || ^12.0
- rakibhstu/number-to-bangla: ^1.5
This package is not auto-updated.
Last update: 2025-12-08 12:53:20 UTC
README
A flexible and customizable Laravel package to format Bangladeshi Taka (৳) with:
- Bangla digits
- Lakh grouping
- Number-to-words conversion (English & Bangla)
- Optional custom font rendering for Blade views, PDFs, and HTML output
📦 Features
- Format Bangladeshi Taka with decimals and thousand/lakh grouping
- Convert numbers to Bangla digits
- Convert numbers to words in English or Bangla
- Customizable fonts, sizes, colors, and styles
- Blade directive support:
@bdt() - Fully configurable via
config/bdt-currency.php
⚙️ Installation
Composer
composer require mazharulslm9/laravel-bdt-currency-helper:dev-main
⚠️ If your package is not on Packagist, add the repository in your Laravel
composer.json:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mazharulslm9/laravel-bdt-currency-helper"
}
]
Then run:
composer require mazharulslm9/laravel-bdt-currency-helper:dev-main
Publish Config
php artisan vendor:publish --provider="Mazharulslm9\BdtCurrency\BDTCurrencyServiceProvider" --tag=bdt-currency-config
This will create:
config/bdt-currency.php
🛠️ Configuration
return [
'symbol' => '৳',
'symbol_position' => 'before',
'decimal_places' => 2,
'decimal_separator' => '.',
'thousand_separator' => ',',
'grouping' => 'lakh',
'language' => 'en',
'use_bangla_words' => true,
'font' => [
'family' => "'Tiro Bangla', serif", // Any custom font
'size' => '16px',
'color' => '#000000',
'weight' => 'normal',
'extra_styles' => null, // Optional extra CSS
],
];
🚀 Usage
1️⃣ Basic Formatting
use Mazharulslm9\BdtCurrency\Facades\BdtCurrency;
echo BdtCurrency::format(123456.78);
// Output: ৳ 1,23,456.78
2️⃣ Number to Words
English
echo BdtCurrency::toWords(1234.50, 'en');
// Output: One thousand two hundred thirty-four taka and fifty paisa
Bangla
echo BdtCurrency::toWords(1234.50, 'bn');
// Output: এক হাজার দুই শত চৌত্রিশ টাকা পঞ্চাশ পয়সা
3️⃣ Custom Fonts in HTML / Blade
echo BdtCurrency::renderHtml(12345.67, [
'font' => [
'family' => "'Tiro Bangla', serif",
'size' => '18px',
'color' => '#2E7D32',
'weight' => 'bold',
'extra_styles' => 'letter-spacing: 0.5px;'
]
]);
Output (HTML span):
<span style="font-family: 'Tiro Bangla', serif; font-size: 18px; color: #2E7D32; font-weight: bold; letter-spacing: 0.5px;">
৳ 12,345.67
</span>
4️⃣ Blade Directive
@bdt(123456.78)
Optional parameters:
@bdt(123456.78, ['language' => 'bn'])
5️⃣ Inline Font Override
{!! BdtCurrency::renderHtml(1234.56, [
'font' => [
'family' => 'Poppins',
'size' => '20px',
'color' => '#ff6600',
'weight' => '600'
]
]) !!}
🔧 Customization Options
| Option | Description |
|---|---|
symbol | Currency symbol (৳) |
symbol_position | before or after |
decimal_places | Number of decimal points |
decimal_separator | Separator for decimals |
thousand_separator | Separator for thousands/lakh |
grouping | lakh or western style |
language | en or bn |
use_bangla_words | Enable Bangla word conversion |
font | family, size, color, weight, extra_styles |
💡 Tips
- Fonts with spaces must be quoted:
'Tiro Bangla', serif - Use
renderHtml()for font styling - For PDFs, Blade views, or HTML, fonts work perfectly
- Plain
format()returns text only — no styling
🧩 Credits
- Bangla Number Conversion: rakibdevs/number-to-bangla
- Developed by Mazharul Islam
📖 Example Combined Usage
{!! BdtCurrency::renderHtml(987654.32, [
'language' => 'bn',
'font' => [
'family' => "'Tiro Bangla', serif",
'size' => '22px',
'color' => '#1E88E5',
'weight' => 'bold'
]
]) !!}
A clean, flexible, and customizable Laravel package for all your Bangladeshi currency formatting needs.