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 Prices

Laravel Prices Laravel Package

whitecube/laravel-prices

Store and work with money in Laravel without floating-point errors. whitecube/laravel-prices wraps integer minor-unit amounts in a Price object with currency support, arithmetic, formatting helpers, and Eloquent casts, so prices stay precise and readable throughout your application.

View on GitHub
Deep Wiki
Context7

Manage acquisition, selling & renting prices for products and services in your Laravel Application

Frequently asked questions about Laravel Prices
How do I install whitecube/laravel-prices in a Laravel app?
Install it with Composer using composer require whitecube/laravel-prices. The package uses Laravel package auto-discovery, so there is no service provider to register manually in a standard app. After installation, add the package's cast to the Eloquent attributes that should be treated as prices.
Which Laravel and PHP versions does whitecube/laravel-prices support?
Version 2.0.0 targets Laravel 13 and PHP 8.5 at the top end and, by elimination from its support matrix, Laravel 11 through 13 on PHP 8.3 through 8.5. It drops Laravel 10 and PHP 8.2, so applications still on those versions must stay on v1.6.x until they upgrade. Confirm the exact constraints in the package's composer.json before adopting.
How do I cast an Eloquent attribute to a Price with whitecube/laravel-prices?
Add the package's cast declaration to the relevant model attribute, such as a price column stored as integer minor units. The cast wraps the stored integer in a Price value object with currency support, so your model returns a readable object instead of a raw number. You do not need a package migration, but you should verify that existing columns store integer minor units and a currency, not floats or preformatted strings.
Does whitecube/laravel-prices avoid floating-point errors?
Yes, when your persistence layer stores amounts as integer minor units, the package wraps those integers in Price objects rather than using floats for arithmetic. That design keeps prices precise and readable throughout the application. If existing columns store floats or preformatted strings, the package will surface inconsistencies rather than fix the underlying data model.
How do I format a Price for display in Blade or an API response?
Price objects include formatting helpers, so you can format amounts for Blade views, JSON resources, or other output layers without manually dividing minor units. Keep formatting on read/display paths and test locale and currency rounding expectations. For write paths, verify that any rounding behavior matches your accounting rules before persisting values.
Can I perform arithmetic on prices and handle multiple currencies?
The package provides Price objects with arithmetic and currency support, so you can add, subtract, and otherwise work with monetary values as objects rather than raw integers. Be explicit about currency matching in your domain logic and test operations that combine amounts. Avoid mixing currencies unless your code and the underlying money library enforce the same currency for each operation.
What database columns should I use with whitecube/laravel-prices?
Use integer columns for minor units and a separate currency column, because the package decorates Eloquent models rather than owning persistence. It fits well where prices are already modelled as integer minor units plus a currency. It is a poor fit for float columns or preformatted price strings, which should be audited and migrated before adoption.
Is whitecube/laravel-prices maintained, and what changed in v2.0.0?
The v2.0.0 release is primarily a platform-support change: it adds Laravel 13 and PHP 8.5 and drops PHP 8.2 and Laravel 10. The generated changelog does not announce API changes, but a semver-major bump means you should confirm the diff and the underlying money library constraint before upgrading. The package is also a single-maintainer project, which is the main long-term maintenance risk to evaluate.
How do I test Eloquent models that use whitecube/laravel-prices casts?
Test them like normal Laravel model tests: create records through factories, assert that the attribute is a Price object, and assert that the database stores the expected integer minor units. Add focused tests for arithmetic, currency handling, and formatting helpers where your application depends on them. Because the package has no runtime service or migration requirement, no special test bootstrap is needed.
What are alternatives to whitecube/laravel-prices for money in Laravel?
Common alternatives include moneyphp/money, brick/money, and custom Eloquent casts built around an integer minor-unit convention. whitecube/laravel-prices is a thin Laravel-side adapter, so its value is the casts and formatting helpers rather than a unique money engine. Compare the underlying money library, Laravel/PHP support floor, and maintainer activity before choosing.
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.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons