Skip to main content

Overview

Laravel Brick Money provides two Blade components for rendering monetary values and currency information in your templates. These components offer a clean, declarative syntax for displaying formatted money and currency data.

Money Component

The <x-money /> component renders formatted monetary values with automatic currency formatting.

Basic Usage

<x-money amount="100"/>
<!-- Output: $100.00 -->

Component Attributes

amount
BigNumber|float|int|string
required
The monetary amount to display. Can be a number, string, or BigNumber instance.
currency
string
default:"config('brick-money.currency')"
The currency code (e.g., “USD”, “EUR”, “GBP”). Defaults to the configured currency in your brick-money.php config file.
minor
bool
default:"config('brick-money.minor')"
Whether the amount is in minor units (e.g., cents). When true, an amount of 100 represents 1.00insteadof1.00 instead of 100.00. Defaults to the configured value in your brick-money.php config file.
context
Context
default:"null"
A Brick\Money\Context instance for custom precision handling. Advanced use cases only.
roundingMode
RoundingMode
default:"RoundingMode::UNNECESSARY"
The rounding mode to use from Brick\Math\RoundingMode. Options include UP, DOWN, CEILING, FLOOR, HALF_UP, HALF_DOWN, HALF_CEILING, HALF_FLOOR, HALF_EVEN, and UNNECESSARY.

Examples

<div class="product-card">
    <h3>{{ $product->name }}</h3>
    <p class="price">
        <x-money 
            :amount="$product->price" 
            :currency="$product->currency"
        />
    </p>
</div>

Implementation Details

The <x-money /> component is implemented in Devhammed\LaravelBrickMoney\View\Components\Money and renders using the money() helper function internally.
// Component class: src/View/Components/Money.php
public function __construct(
    public BigNumber|float|int|string $amount,
    public ?string $currency = null,
    public ?bool $minor = null,
    public ?Context $context = null,
    public RoundingMode $roundingMode = RoundingMode::UNNECESSARY
) {
    //
}
The component template simply calls the money() helper:
{{-- resources/views/components/money.blade.php --}}
{{ money($amount, $currency, $minor, $context, $roundingMode) }}

Currency Component

The <x-currency /> component renders formatted currency information.

Basic Usage

<x-currency currency="USD"/>
<!-- Output: USD -->

Component Attributes

currency
string
required
The currency code to display (e.g., “USD”, “EUR”, “GBP”).

Examples

<div class="account-info">
    <span>Account Currency:</span>
    <span><x-currency :currency="$account->currency_code"/></span>
</div>

Implementation Details

The <x-currency /> component is implemented in Devhammed\LaravelBrickMoney\View\Components\Currency and renders using the currency() helper function internally.
// Component class: src/View/Components/Currency.php
public function __construct(public string $currency)
{
    //
}
The component template simply calls the currency() helper:
{{-- resources/views/components/currency.blade.php --}}
{{ currency($currency) }}

Component Registration

Both components are automatically registered in the package service provider:
// src/Provider.php
Blade::component('money', View\Components\Money::class);
Blade::component('currency', View\Components\Currency::class);
The components are available as soon as you install the package. No additional configuration is required.

Build docs developers (and LLMs) love