Nasrul Hazim Bin Mohamad

Laravel: MoneyPHP Wrapper and Helper

Dec
19

I’ve created a simple MoneyPHP wrapper to simplify my day to day work dealing with MoneyPHP.

and a currency configuration – where you can specify the label for display use, and swift_code for MoneyPHP usage:

And I’ve create a helper in my app/Support/helpers.php, to simplify the usage of the MoneyPHP Wrapper.

A simple usage as following:

money()->toHuman(10000) – use it for display it to end user.

money()->toMachine(10000) – use it for create the right format before use in database or calculation.

money()->toCommon(10000) – use if for common display at the frontend.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

four + five =