Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Money

Laravel Money Laravel Package

elegantly/laravel-money

Seamlessly integrate Brick/Money with Laravel using expressive value objects. MoneyCast automatically casts Eloquent attributes to Money, MoneyParser safely converts strings, integers, and floats, and the ValidMoney rule validates input with min/max boundaries and nullable support.

View on GitHub
Deep Wiki
Context7

elegantly/laravel-money brings seamless, expressive integration of Brick/Money to Laravel, enabling safe and precise handling of monetary values through value objects instead of floats. It fits naturally into Eloquent models and Laravel's validation system, making money handling both robust and readable.

  • MoneyCast – Automatically cast Eloquent attributes to Brick\Money\Money instances.
  • Currency-aware casting – Use a dedicated currency column or a fixed currency per attribute.
  • MoneyParser – Safely convert strings, integers, or floats into Money objects.
  • ValidMoney rule – Validate input with min/max boundaries, type safety, and nullability.
  • Publishable config – Customize defaults via php artisan vendor:publish.
Frequently asked questions about Laravel Money
How do I install elegantly/laravel-money in a Laravel app?
Install via Composer with composer require elegantly/laravel-money. Laravel auto-discovers the service provider. Optionally publish the config file with php artisan vendor:publish --tag="money-config" to customize defaults.
How do I cast an Eloquent attribute to a Brick Money object?
Use the MoneyCast cast on your model attribute. Define it in the $casts array, either pointing to a currency column or passing a fixed currency. The attribute will then return a Brick\Money\Money instance.
What database columns should I use to store money with laravel-money?
The recommended schema is a bigInteger column for the amount in the smallest currency unit and a string column for the ISO currency code. This avoids floating-point errors and supports precision. Existing decimal or float columns can be parsed but may sacrifice precision.
How does laravel-money handle multi-currency models?
You can cast with a currency column so each record stores its own currency, enabling dynamic multi-currency support. Alternatively, use a fixed currency per model or field when the currency is constant. This supports global applications without architectural changes.
How do I validate monetary input in Laravel with this package?
Use the provided ValidMoney validation rule in Form Requests or inline validators. It supports min/max boundaries, type safety, and nullability. This helps sanitize API and user-facing monetary input.
How can I parse strings or numbers into Money objects?
The MoneyParser converts strings, integers, and floats into Brick\Money\Money instances safely. It handles common monetary formats and eases integration with external systems. Use it when you need to normalize input before storage or calculation.
Which Laravel versions does elegantly/laravel-money support?
The package officially supports Laravel 10 through 12. It integrates with Eloquent, Form Requests, Livewire, and validation pipelines. Check the repository for any future version updates.
Can I use laravel-money with existing decimal or float database columns?
Backward-compatible parsing exists, but storing money as decimal or float can sacrifice precision. For optimal precision, migrate to bigInteger amount plus string currency columns. Plan a careful rounding strategy if migrating existing data.
How are Money objects serialized to JSON in APIs?
Money objects serialize to floats by default, such as 100.00. If your API contract expects strings like "USD 100.00", customize serialization in your resources or casts. Consider standardizing output format across endpoints.
Does laravel-money support currency conversion or exchange rates?
No, the package focuses on storage, casting, parsing, and validation of monetary values. It does not provide real-time currency conversion or exchange rates. Integrate a separate exchange rate service if conversion is required.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle
glavweb/extra-bundle
glavweb/api-bundle
glavweb/admin-bundle