📜 ⬆️ ⬇️

Number written in Laravel 5

Sometimes it is necessary to display the number in words when forming a form and the DigitText module designed specifically for the Laravel framework comes to the rescue.

It allows you to process any number in any language.

image

')

Installation


Installing the module is very simple:

1. Run the following commands in sequence:

composer require andrey-helldar/digittext composer update 

2. After updating the composer, add the service provider to the `config / app.php` file:

 Helldar\DigitText\DigitServiceProvider::class, 

3. Next, in the same file, add a facade to the `aliases` section:

 'DigitText' => Helldar\DigitText\DigitText::class, 

Done!

Using


To translate a number into text, use the following construction:
 DigitText::text($number = 0, $lang = 'ru', $currency = false); 


Example:
 DigitText::text(); DigitText::text(64.42); DigitText::text(2866); DigitText::text(0, 'ru', true); DigitText::text(64.42, 'ru', true); DigitText::text(2866, 'ru', true); /* * : *  *   *      * *   *    42  *       */ 


Language forms


At the time of this writing, the module supports work with such language forms as: “Russian”, “English” and “German”.

Anyone can help the development of the module DigitText .

The module is licensed under the MIT.

From the author


This is my first module under Laravel. I know that the code is far from ideal and please do not kick much :)

To minus


If you do not share the opinion of the author, please describe your point of view constructively in the comments.

Source: https://habr.com/ru/post/279293/


All Articles