PHPackages                             andriichuk/laracash - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. andriichuk/laracash

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

andriichuk/laracash
===================

PHP Laravel Money Package

v2.2.0(1y ago)74108.2k—0%12[1 PRs](https://github.com/andriichuk/laracash/pulls)1MITPHPPHP ^8.0

Since Mar 21Pushed 1y ago4 watchersCompare

[ Source](https://github.com/andriichuk/laracash)[ Packagist](https://packagist.org/packages/andriichuk/laracash)[ RSS](/packages/andriichuk-laracash/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (8)Versions (23)Used By (1)

PHP Laravel Money Package
=========================

[](#php-laravel-money-package)

[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine/)

 [![Logo](https://github.com/andriichuk/laracash/raw/master/docs/logo.png)](https://github.com/andriichuk/laracash/blob/master/docs/logo.png)

[![GitHub stars](https://camo.githubusercontent.com/989b1a45aedada383e6dbff361a527fb8028a6de64ae5d4ebfcbcf7198b0bff1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f616e647269696368756b2f6c61726163617368)](https://github.com/andriichuk/laracash)[![Total Downloads](https://camo.githubusercontent.com/2cb75d1ad7a82b51a04e693586637482d6c912003e42109dfd54c4def8003dd3/68747470733a2f2f706f7365722e707567782e6f72672f616e647269696368756b2f6c617261636173682f646f776e6c6f6164733f666f726d61743d666c6174)](https://packagist.org/packages/andriichuk/laracash)[![Latest Stable Version](https://camo.githubusercontent.com/9b32011194a5eab92ab309eba4c4d8b73f9151ec4e8dc3bcfa01cceede59884b/68747470733a2f2f706f7365722e707567782e6f72672f616e647269696368756b2f6c617261636173682f762f737461626c653f666f726d61743d666c6174)](https://packagist.org/packages/andriichuk/laracash)[![Psalm type coverage](https://camo.githubusercontent.com/fe8242b1a6197c8e8f794030562e8fed9abc83663e0b099b94d0798fb4c122d6/68747470733a2f2f73686570686572642e6465762f6769746875622f616e647269696368756b2f6c617261636173682f636f7665726167652e737667)](https://packagist.org/packages/andriichuk/laracash)[![Psalm enabled](https://camo.githubusercontent.com/9cf29f0ac3f35cf440801def4f78811d9641ac337f048ab883567a0513aff205/68747470733a2f2f73686570686572642e6465762f6769746875622f616e647269696368756b2f6c617261636173682f6c6576656c2e737667)](https://packagist.org/packages/andriichuk/laracash)[![License](https://camo.githubusercontent.com/8b70a199efc99c3c0ed5f9ad87e26aa75a22a333ec3810e9ef1d323588dd20bd/68747470733a2f2f706f7365722e707567782e6f72672f616e647269696368756b2f6c617261636173682f6c6963656e73653f666f726d61743d666c6174)](https://packagist.org/packages/andriichuk/laracash)

- Laravel wrapper over the [MoneyPHP](https://github.com/moneyphp/money) library
- Provides a convenient way to work with the money column as a Value Object
- Uses the [Custom Casts](https://laravel.com/docs/7.x/eloquent-mutators#custom-casts) Laravel 7.x feature

Table of Contents
=================

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- Supported concepts
    - [Money columns with default Currency (without a specific column)](#money-columns-with-default-currency)
    - [Currency columns without Money](#currency-columns-without-money)
    - [Multiple Money columns refer to one Currency column](#multiple-money-columns-refer-to-one-currency-column)
    - [Money to Currencies columns mapping](#money-to-currencies-columns-mapping)
- [Display money data in the form input field](#display-money-data-in-the-form-input-field)
- [Parse money from request field](#parse-money-from-request-field)
- [Using in API resources](#using-in-api-resources)
- [Model creation](#model-creation)
- [Bitcoin creation](#bitcoin-creation)
- [Retrieving data](#retrieving-data)
- [Operations](#operations)
- Library API
    - [Creation](#creation)
    - [Formatting](#formatting)
    - [Bitcoin](#bitcoin)
    - [Parsing](#parsing)

### Features

[](#features)

- Convenient work with the native the MoneyPHP library and Laravel Eloquent ORM
- Money columns casting
- Currencies columns casting
- Supported concepts
    - Money columns with default Currency (without a specific column)
    - Currency columns without Money
    - Many Money columns reference to one Currency column
    - Money to Currencies columns mapping

### Requirements

[](#requirements)

- PHP ^8.0
- Laravel v7.x|v8.x

Suggest

- BCMath (`ext-bcmath`) and GMP (`ext-gmp`) PHP Extensions for calculations with large integers
- Intl PHP Extension (`ext-intl`) for formatting

### Installation

[](#installation)

Require package

```
composer require andriichuk/laracash
```

Publish vendor settings

```
php artisan vendor:publish --provider="Andriichuk\Laracash\ServiceProviders\LaracashServiceProvider" --tag="config"
```

Default settings

```
[
    'currency' => 'USD',
    'locale' => 'en_US',
]
```

### Usage Concepts

[](#usage-concepts)

#### Money columns with default Currency

[](#money-columns-with-default-currency)

```
