PHPackages                             ejetar/laravel-decimal-locale - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Localization &amp; i18n](/categories/localization)
4. /
5. ejetar/laravel-decimal-locale

ActiveLibrary[Localization &amp; i18n](/categories/localization)

ejetar/laravel-decimal-locale
=============================

🔄 Cast your model attributes to the decimal format of another location.

1.0.0(5y ago)46[2 PRs](https://github.com/ejetar/laravel-decimal-locale/pulls)MITPHPPHP &gt;=7.4

Since Feb 2Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ejetar/laravel-decimal-locale)[ Packagist](https://packagist.org/packages/ejetar/laravel-decimal-locale)[ Docs](https://ejetar.com/projects/laravel-decimal-locale)[ RSS](/packages/ejetar-laravel-decimal-locale/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (4)Versions (4)Used By (0)

Laravel Decimal Locale
======================

[](#laravel-decimal-locale)

🔄 Cast your model attributes to the decimal format of another location.

Table of Contents
-----------------

[](#table-of-contents)

- [How it works](#how-it-works)
- [Compatibility](#compatibility)
    - [Example 1](#example-1)
        - [Output](#output)
    - [Example 2](#example-2)
        - [Output](#output-1)
    - [Example 3](#example-3)
        - [Output](#output-2)
- [Installation](#installation)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [License](#license)

How it works
------------

[](#how-it-works)

The laravel-decimal-locale library allows you to convert decimal numbers to the format of different locations.

**Example**

1000.5 to:

Locale CodeLocale NameResult.........afAfrikaans1.000,5arArabic1,000.5ar-AEArabic (U.A.E.)١٬٠٠٠٫٥bg-BGBulgarian (Bulgaria)1000,5csCzech1 000,5de-CHGerman (Switzerland)1’000.5.........This library was born with the main objective of providing, in a simple way, the possibility of converting decimal numbers into API responses. Therefore, currently there is only one way to inform the application what the location you want is by request, through the `DecimalLocale` header. You are free to expand the possibilities of this solution, I will be very happy to receive your contribution. :)

But let's get down to business...

This package provides an attribute conversion class called `Decimal`. All you need to do is:

1. In the desired Model, add the cast to the desired attribute. Just like the example below:

```
