Coder Social home page Coder Social logo

dotartisan / laravel-money Goto Github PK

View Code? Open in Web Editor NEW

This project forked from akaunting/laravel-money

0.0 0.0 1.0 103 KB

Currency formatting and conversion package for Laravel

Home Page: https://developer.akaunting.com

License: MIT License

PHP 99.94% Blade 0.06%

laravel-money's Introduction

Currency formatting and conversion package for Laravel

Downloads Tests StyleCI License

This package intends to provide tools for formatting and conversion monetary values in an easy, yet powerful way for Laravel projects.

Why not use the moneyphp package?

Because it uses the intl extension for number formatting. intl extension isn't present by default on PHP installs and can give different results in different servers.

Getting Started

1. Install

Run the following command:

composer require akaunting/laravel-money

2. Publish

Publish config file.

php artisan vendor:publish --tag=money

3. Configure

You can change the currencies information of your app from config/money.php file

Usage

use Akaunting\Money\Currency;
use Akaunting\Money\Money;

echo Money::USD(500); // '$5.00' unconverted
echo new Money(500, new Currency('USD')); // '$5.00' unconverted
echo Money::USD(500, true); // '$500.00' converted
echo new Money(500, new Currency('USD'), true); // '$500.00' converted

Advanced

$m1 = Money::USD(500);
$m2 = Money::EUR(500);

$m1->getCurrency();
$m1->isSameCurrency($m2);
$m1->compare($m2);
$m1->equals($m2);
$m1->greaterThan($m2);
$m1->greaterThanOrEqual($m2);
$m1->lessThan($m2);
$m1->lessThanOrEqual($m2);
$m1->convert(Currency::GBP, 3.5);
$m1->add($m2);
$m1->subtract($m2);
$m1->multiply(2);
$m1->divide(2);
$m1->allocate([1, 1, 1]);
$m1->isZero();
$m1->isPositive();
$m1->isNegative();
$m1->format();

Helpers

money(500, 'USD')
currency('USD')

Blade Directives

@money(500, 'USD')
@currency('USD')

Blade Component

Same as the directive, there is also a blade component for you to create money and currency in your views:

<x-money amount="500" currency="USD" />
or
<x-money amount="500" currency="USD" convert />

<x-currency currency="USD" />

Changelog

Please see Releases for more information on what has changed recently.

Contributing

Pull requests are more than welcome. You must follow the PSR coding standards.

Security

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see LICENSE for more information.

laravel-money's People

Contributors

denisdulici avatar cuneytsenturk avatar fridzema avatar alanbrande avatar alliuqemal avatar buzzclue avatar dylan-dpc avatar lguima avatar shamarkellman avatar dmcbrn avatar

Forkers

gauravkumar-dev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.