Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Number To Bangla Laravel Package

rakibhstu/number-to-bangla

Laravel package that converts English numbers into Bangla digits, words, money format, currency, ordinals, month names, and dates. It includes reverse parsing, a fluent API, lakh comma formatting, date output, and supports Laravel 9.x-12.x for applications with values up to 999999999999999.

View on GitHub
Deep Wiki
Context7

Number to Bangla Number, Word or Month Name in Laravel

Packagist GitHub stars GitHub forks GitHub issues GitHub license Tests

Laravel package to convert English numbers to Bangla number or Bangla text, Bangla month name and Bangla Money Format for Laravel 9.x, 10.x, 11.x, and 12.x.

Maximum possible number to convert in Bangla word is 999999999999999

Get Wordpress Plugin

Features

Operation English Input Bangla Output
Text (Integer) 13459 তেরো হাজার চার শত ঊনষাট
Text (Float) 1345.05 এক হাজার তিন শত পঁয়তাল্লিশ দশমিক শূন্য পাঁচ
Number 1345.5 ১৩৪৫.৫
Text Money Format 1345.50 এক হাজার তিন শত পঁয়তাল্লিশ টাকা পঞ্চাশ পয়সা
Currency 1500.25 এক হাজার পাঁচ শত টাকা পঁচিশ পয়সা
Ordinal 1 প্রথম
Month 12 ডিসেম্বর
Date 2024-01-15 ১৫ জানুয়ারি, ২০২৪
Comma (Lakh) 121212121 ১২,১২,১২,১২১

Requirements

  • PHP 8.0 or higher
  • Laravel 9.x, 10.x, 11.x, or 12.x

Complete Usage Guide - NumberToBangla v2.1

🚀 Installation

composer require rakibhstu/number-to-bangla:^2.1

📖 Table of Contents

  1. Basic Number Conversion
  2. Date & Time
  3. Advanced Features
  4. Reverse Parsing
  5. Fluent API

Basic Number Conversion

Number to Bangla Digits

use Rakibhstu\Banglanumber\NumberToBangla;

$numto = new NumberToBangla();

echo $numto->bnNum(12345);
// Output: ১২৩৪৫

echo $numto->bnNum(1234.56);
// Output: ১২৩৪.৫৬

Number to Bangla Words

echo $numto->bnWord(12345);
// Output: বারো হাজার তিন শত পঁয়তাল্লিশ

echo $numto->bnWord(1345.05);
// Output: এক হাজার তিন শত পঁয়তাল্লিশ দশমিক শূন্য পাঁচ

Comma Separated (Lakh Format)

echo $numto->bnCommaLakh(1234567);
// Output: ১২,৩৪,৫৬৭

Percentage

echo $numto->bnPercentage(75.5);
// Output: ৭৫.৫%

echo $numto->bnPercentage(75.5, asWord: true);
// Output: পঁচাত্তর দশমিক পাঁচ শতাংশ

Currency Formatting

Money Format (Taka/Paisa)

echo $numto->bnMoney(5000);
// Output: পাঁচ হাজার টাকা

echo $numto->bnMoney(5000.50);
// Output: পাঁচ হাজার টাকা পঞ্চাশ পয়সা

echo $numto->bnCurrency('1500.25');
// Output: এক হাজার পাঁচ শত টাকা পঁচিশ পয়সা

Date & Time

Month Names

echo $numto->bnMonth(1);
// Output: জানুয়ারি

echo $numto->bnMonth(12);
// Output: ডিসেম্বর

Day Names

echo $numto->bnDay(1);
// Output: রবিবার

echo $numto->bnDay('monday');
// Output: সোমবার

Time Formatting

echo $numto->bnTime('14:30');
// Output: দুপুর ২:৩০

echo $numto->bnTime('14:30', asWord: true);
// Output: দুপুর দুইটা ত্রিশ মিনিট

echo $numto->bnTime('09:15', asWord: true);
// Output: সকাল নয়টা পনেরো মিনিট

Duration

echo $numto->bnDuration(3665);
// Output: ১ ঘন্টা ১ মিনিট ৫ সেকেন্ড

echo $numto->bnDuration(90);
// Output: ১ মিনিট ৩০ সেকেন্ড

Bengali Calendar

echo $numto->bnBengaliMonth(1);
// Output: বৈশাখ

echo $numto->bnSeason(1);
// Output: গ্রীষ্ম

echo $numto->bnSeason(5);
// Output: শীত

Age Calculator

echo $numto->bnAge('1990-01-15');
// Output: ৩৫ বছর

echo $numto->bnAge('1990-01-15', detailed: true);
// Output: ৩৫ বছর ২ মাস ৫ দিন

Date Formatting

echo $numto->bnDate('2024-01-15');
// Output: ১৫ জানুয়ারি, ২০২৪

echo $numto->bnDate('2024-01-15', 'l, d F Y');
// Output: সোমবার, ১৫ জানুয়ারি ২০২৪

echo $numto->bnWeekNumber('2024-01-15');
// Output: ৩

echo $numto->bnOrdinal(1);
// Output: প্রথম
// Output: ১৫ জানুয়ারি, ২০২৪

---
## Reverse Parsing

### Parse Bangla Numbers to English
```php
$number = $numto->parseNum('১২৩৪৫');
// Output: 12345

$number = $numto->parseNum('১২,৩৪,৫৬৭');
// Output: 1234567

Fluent API

Beautiful Chaining

$result = $numto->number(12345)
                ->toBangla()
                ->asWord()
                ->withPrefix('মোট: ')
                ->withSuffix(' টাকা')
                ->get();
// Output: মোট: বারো হাজার তিন শত পঁয়তাল্লিশ টাকা

Different Formats

// As percentage
$result = $numto->number(75.5)
                ->asPercentage(asWord: true)
                ->get();
// Output: পঁচাত্তর দশমিক পাঁচ শতাংশ

Batch Processing

Convert Multiple Numbers

$numbers = [100, 200, 300];
$result = $numto->batch($numbers, 'bnNum');
// Output: ['১০০', '২০০', '৩০০']

$result = $numto->batch($numbers, 'bnWord');
// Output: ['এক শত', 'দুই শত', 'তিন শত']

With Associative Arrays

$data = [
    'revenue' => 500000,
    'expenses' => 200000,
    'profit' => 300000
];

$result = $numto->batchWithKeys($data, 'bnCurrency');
// Output: [
//   'revenue' => '৫ লক্ষ টাকা',
//   'expenses' => '২ লক্ষ টাকা',
//   'profit' => '৩ লক্ষ টাকা'
// ]

API Integration

Convert to Array

$result = $numto->toArray(12345);
/* Output:
[
    'original' => 12345,
    'bangla_number' => '১২৩৪৫',
    'bangla_word' => 'বারো হাজার তিন শত পঁয়তাল্লিশ',
    'money_format' => 'বারো হাজার তিন শত পঁয়তাল্লিশ টাকা',
    'comma_format' => '১২,৩৪৫'
]
*/

Convert to JSON

$json = $numto->toJson(12345);
// Returns UTF-8 encoded JSON string

In API Controllers

public function show($id)
{
    $product = Product::find($id);
    
    return response()->json([
        'name' => $product->name,
        'price' => NumberToBangla::convert($product->price),
        'price_words' => NumberToBangla::words($product->price),
        'discount' => [
            'rate' => app(NumberToBangla::class)->bnPercentage($product->discount),
            'amount' => NumberToBangla::money($product->discount_amount)
        ],
        'details' => app(NumberToBangla::class)->toArray($product->price)
    ]);
}

Static Helpers

Quick One-Liners

use Rakibhstu\Banglanumber\NumberToBangla;

// In controllers
$banglaNumber = NumberToBangla::convert(12345);

// In Blade
{{ NumberToBangla::words($amount) }}
{{ NumberToBangla::money($total) }}

// In models
public function getPriceAttribute($value)
{
    return NumberToBangla::convert($value);
}

Real-World Use Cases

E-Commerce

$discount = $numto->bnPercentage(20);
$final = $numto->bnMoney(20000);

// Stock display
$stock = $numto->bnWord(50) . ' পিস';

Education

$marks = $numto->bnNum(85);
$percentage = $numto->bnPercentage(85);

Official

// Official documents
$amount = $numto->bnMoney(50000);
$date = $numto->bnDate('2024-01-15');
$age = $numto->bnAge('1990-01-01');

Performance Tips

  1. Batch Processing: Use batch() for multiple conversions
  2. Static Helpers: Use for simple, one-off conversions
  3. Fluent API: Chain multiple operations efficiently

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Support

If you find this package helpful, please consider giving it a ⭐ on GitHub!

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package