https://github.com/vyuldashev/nova-money-field
Money Field for Laravel Nova
https://github.com/vyuldashev/nova-money-field
currency laravel money nova php
Last synced: over 1 year ago
JSON representation
Money Field for Laravel Nova
- Host: GitHub
- URL: https://github.com/vyuldashev/nova-money-field
- Owner: vyuldashev
- Created: 2018-08-24T11:03:24.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-03-22T14:33:38.000Z (over 2 years ago)
- Last Synced: 2025-04-03T20:13:41.505Z (over 1 year ago)
- Topics: currency, laravel, money, nova, php
- Language: Vue
- Homepage: https://novapackages.com/packages/vyuldashev/nova-money-field
- Size: 1.11 MB
- Stars: 74
- Watchers: 2
- Forks: 37
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Money Field for Laravel Nova
[](https://packagist.org/packages/vyuldashev/nova-money-field)
[](https://packagist.org/packages/vyuldashev/nova-money-field)

## Installation
You can install the package in to a Laravel app that uses [Nova](https://nova.laravel.com) via composer:
```bash
composer require vyuldashev/nova-money-field
```
## Usage
In resource:
```php
// ...
use Vyuldashev\NovaMoneyField\Money;
public function fields(Request $request)
{
return [
// ...
Money::make('Balance'),
];
}
```
USD currency is used by default, you can change this by passing second argument:
```php
Money::make('Balance', 'EUR'),
```
You may use `locale` method to define locale for formatting value, by default value will be formatted using browser locale:
```php
Money::make('Balance')->locale('ru-RU'),
```
If you store money values in database in minor units use `storedInMinorUnits` method. Field will automatically convert minor units to base value for displaying and to minor units for storing:
```php
Money::make('Balance', 'EUR')->storedInMinorUnits(),
```
If you need to use a name that doesn't convert to the column name (eg 'Balance' as name and `remaining_balance` as column) you can pass this as the 3rd argument to the make/constructor.
Please Note: that this, along with all field column names, should be present and usable within your model class else you may encounter SQL errors.
```php
Money::make('Balance', 'EUR', 'remaining_balance'),
```