evryn/laravel-toman
Laravel Toman makes it easy to work with Iranian currency: convert Rial to Toman, format and localize prices, validate amounts, and handle Persian numerals. A lightweight helper package for clean, consistent money handling in Laravel apps.
Install the package
composer require evryn/laravel-toman
v4.1.0 adds Laravel 12 support — this is the only change since v4.0.0, so no API or config changes are required when upgrading from v4.x. If you are on Laravel 11 or older, 4.1.0 still works; Laravel 12 is now simply allowed by the constraint.
Publish the config
php artisan vendor:publish --tag=toman-config
This lands config/toman.php. Review it before writing any formatting code — prefix/suffix, separator, decimals, and locale here drive every formatted output in the app.
First use case — display prices Prices in Iranian commerce are typically stored in Rial, but users expect Toman (Rial ÷ 10). Convert at the presentation boundary:
toman(1500000); // 150000 (Rial -> Toman)
In Blade:
@toman($product->price_rial)
Where to look first
config/toman.php — formatting behaviour.toman validation rule and Blade directive — these are the two integrations you'll reach for most.public function getPriceTomanAttribute(): string
{
return toman($this->price_rial);
}
@toman(...) instead of number_format($price / 10). It keeps separators, decimals, and suffix consistent across every view and picks up config changes automatically.Toman facade (or the helper) in a dedicated presenter/resource rather than in the controller.return [
'price_rial' => $order->price_rial,
'price_toman' => toman($order->price_rial),
];
toman validation rule when accepting user-entered amounts in Toman (forms, admin panels) so input matches your display unit. If the field is Rial, validate as numeric instead and convert downstream.$response->assertSee(toman(1500000));
laravel/framework: ^12.0 and re-run the suite to confirm nothing relies on removed framework APIs.price_rial, price_toman) and never rely on context.toman rule validates/parses a Toman input, not Rial. Mixing units across validation and persistence is a common source of off-by-10 bugs.php artisan config:cache in production and clear it after edits.{{ }} vs {!! !!} — double-escaping HTML entities in suffixes is a nuisance.^4.1 if you're on Laravel 12; otherwise ^4.0 remains safe.How can I help you explore Laravel packages today?