Documentation Index
Fetch the complete documentation index at: https://mintlify.com/devhammed/laravel-brick-money/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Laravel Brick Money provides powerful formatting capabilities to display money values in different formats, locales, and styles. You can use simple formatting or advanced locale-aware formatting with full NumberFormatter customization.Basic Formatting
Theformat() method provides simple, currency-aware formatting:
Format Configuration
The basicformat() method uses currency-specific settings:
Symbol Position
Automatically positions symbol before or after the amount based on currency conventions
Symbol Spacing
Adds space between symbol and amount when appropriate (e.g., “EUR 100,00”)
Decimal Separator
Uses
. for USD, , for EUR, etc.Thousands Separator
Uses
, for USD, . for EUR, etc.Whole Number Formatting
You can optionally hide decimal places for whole numbers:Locale-Aware Formatting
TheformatLocale() method uses PHP’s NumberFormatter for internationalized formatting:
Basic Locale Formatting
Default Locale
Set a default locale for all formatting:Locale with Whole Numbers
NumberFormatter Customization
You can customize the NumberFormatter with a callback for advanced formatting needs:Custom Number Format Attributes
- Accounting Format
- No Grouping
- Custom Decimals
- Padding
Practical Formatting Examples
Price Display Component
Multi-Currency Invoice
Cryptocurrency Formatting
View Integration
Blade Directives
Blade Components
Comparison of Format Methods
| Feature | format() | formatLocale() |
|---|---|---|
| Performance | Faster (uses number_format) | Slower (uses NumberFormatter) |
| Locale Support | Basic (currency settings) | Full (NumberFormatter) |
| Customization | Limited | Extensive (callback) |
| Best For | Simple display, APIs | User-facing interfaces |
Best Practices
Choose the Right Method
Choose the Right Method
- Use
format()for consistent, fast formatting - Use
formatLocale()when displaying to users in different locales - Use
formatLocale()with callback for accounting or special formats
Performance Considerations
Performance Considerations
formatLocale() creates a new NumberFormatter instance on each call. For bulk formatting, consider caching the formatter:Floating Point Precision
Floating Point Precision
Both methods use
toFloat() internally, which can introduce precision errors for very large amounts. For large values, consider custom formatting:Locale String Format
Locale String Format
Always use underscores in locale strings (
en_US), not hyphens (en-US). The package automatically converts hyphens:Next Steps
Extensions
Learn how to extend Money with custom formatting macros
JSON Serialization
Customize how Money is serialized to JSON