naimcse56/float-spellout

This is a Laravel Package to convert float number to words

dev-main 2024-09-30 10:38 UTC

This package is auto-updated.

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


README

Package for Laravel Developers to Convert Number to Words.

composer require naimcse56/float-spellout:dev-main

Add This in config/app.php

Naimcse56\FloatSpellout\FloatSpelloutServiceProvider::class

You can inject the service into your controller and use it to convert float numbers:

use Naimcse56\FloatSpellout\Contracts\NumberSpelloutContract;

class NumberController extends Controller
{
    private $spelloutService;

    public function __construct(NumberSpelloutContract $spelloutService)
    {
        $this->spelloutService = $spelloutService;
    }

    public function show($number)
    {
        $spelledOutNumber = $this->spelloutService->convert(floatval($number));
        return response()->json(['spelled_out' => $spelledOutNumber]);
    }
}

Or You can also do this below

use Naimcse56\FloatSpellout\Services\FloatNumberSpelloutService;

$service = new FloatNumberSpelloutService();
$result = $service->convert(123.45);

// Output will be 'one hundred twenty-three point four five'