---
title: "Prices — Advertisements for Laravel | Roundly"
description: "Prices are exact Money values in a decimal(38,0) minor-unit column — no floats, currency-safe writes, numeric ordering and API resources."
url: https://roundly-consulting.com/open-source/docs/advertisements-for-laravel/prices
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Advertisements for Laravel](https://roundly-consulting.com/open-source/docs/advertisements-for-laravel.md)

# Prices

price is cast with money-for-laravel’s AsMoney::currencyColumn('currency') to a RoundlyConsulting\\Money\\Money: the amount lives in price as minor units (a decimal(38,0) column), the code in currency.

```php
use RoundlyConsulting\Money\Money;

$ad->price = Money::ofMajor('15.00', 'EUR');
$ad->price->minor();        // "1500" — a string, never (int)-cast it
$ad->price->toDecimal();    // "15.00"
$ad->price->format('sk');   // formatted for the Slovak locale
$ad->currency;              // "EUR"

$ad->price?->add(Money::ofMinor(500, 'EUR'));      // money's API; mismatched currencies throw CurrencyMismatch

Advertisement::query()->orderBy('price')->get();   // numeric order
```

## Rules

- Only Money|null can be assigned; anything else throws RoundlyConsulting\\Money\\Exceptions\\InvalidMoneyValue.
- Assigning a price in another currency to a priced ad throws CurrencyMismatch — set currency first to re-denominate on purpose (UpdateAdvertisement does this for you).
- Writing null clears the amount and keeps currency.
- PostgreSQL and MySQL store all 38 digits; SQLite is exact only within int64, so the cast refuses wider amounts there (InvalidMoneyValue) instead of silently storing a float.
- The text-ad fallback renders $ad->price->format() in the active locale.

## API resources

Render the price with money’s resource — from() returns null for a price-less ad:

```php
use RoundlyConsulting\Money\Http\Resources\MoneyResource;

'price' => MoneyResource::from($ad->price),
// {"minor":"1999","decimal":"19.99","currency":"EUR","exponent":2,"formatted":"…"}
// "formatted" follows the active app locale: app()->setLocale('sk') changes it
```

minor is a JSON string on purpose; a frontend doing arithmetic reads decimal (or BigInt(minor)). formatted follows the active app locale (app()->setLocale()), so it changes with the request’s language — display it, never parse it. Arithmetic, formatting, currencies and rounding are covered in the Money for Laravel docs.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/advertisements-for-laravel.md)
