Guides
Directives & helpers
The Blade directives and PHP helpers behind the components.
For values inside a sentence, where a component would be too much. The digit and money directives (@fa, @faNum, @toman, @rial) are Persian by definition — @toman always says تومان; @jalali follows config('mds.persian_digits') like the components do. This page's examples read right-to-left, the way these directives are used.
قیمت این کالا ۲٬۵۰۰٬۰۰۰ تومان است و در ۲۹ مرداد ۱۴۰۵ ثبت شده. کد پیگیری: ۱۴۰۵۲۹
<flux:text>
قیمت این کالا @toman(2500000) است و در
@jalali('2026-08-20') ثبت شده. کد پیگیری: @fa(140529)
</flux:text>
Numbers
@fa(1405) {{-- ۱۴۰۵ --}}
@faNum(2500000) {{-- ۲٬۵۰۰٬۰۰۰ --}}
Money and dates
@toman(2500000) {{-- ۲٬۵۰۰٬۰۰۰ تومان --}}
@rial(14500000) {{-- ۱۴٬۵۰۰٬۰۰۰ ریال --}}
@jalali('2026-08-20') {{-- ۲۹ مرداد ۱۴۰۵ --}}
PHP helpers
The same conversions, for use outside a view — in a model accessor, a job, an export.
use MajidDs\Support\Persian;
use MajidDs\Support\Jalali;
Persian::digits(1405); // ۱۴۰۵
Persian::latinDigits('۱۴۰۵'); // 1405
Persian::number(2500000); // ۲٬۵۰۰٬۰۰۰
Persian::money(2500000); // ۲٬۵۰۰٬۰۰۰ تومان
Persian::fileSize(162400); // ۱۵۹ کیلوبایت
Persian::ago(now()->subHours(3)); // ۳ ساعت پیش
Jalali::format('2026-08-20', 'l j F Y'); // پنجشنبه ۲۹ مرداد ۱۴۰۵
Jalali::fromGregorian(2026, 8, 23); // [1405, 6, 1]
Jalali::toGregorian(1405, 6, 1); // [2026, 8, 23]
// Both helpers can speak English too — Latin digits,
// transliterated month names, English units:
Persian::fileSize(162400, false); // 159 KB
Persian::ago(now()->subHours(3), false); // 3 hours ago
Jalali::format('2026-08-20', 'j F Y', false); // 29 Mordad 1405
Latin digits when you need them
Persian digits are display-only. Anything that has to survive a round trip — a form value, a URL, a database column — should hold Latin digits. Persian::latinDigits() is the way back, and components like mds:quantity already keep their hidden input in Latin for exactly this reason.
Reference
Directives
| Prop | Description |
|---|---|
| @fa | Persian digits: @fa(1405). |
| @faNum | Persian digits with the ٬ thousands separator. |
| @toman | Amount plus تومان. Always Persian. |
| @rial | Amount plus ریال. Always Persian. |
| @jalali | Jalali date: @jalali($date, $format = 'j F Y'). Follows mds.persian_digits — Persian names and digits when on, 29 Mordad 1405 when off. |
| @mdsNonce | Inside a <script tag: the nonce attribute for the CSP nonce registered with Vite::useCspNonce(), or nothing. Every script in the kit carries it — see Content Security Policy. |
MajidDs\Support\Persian
| Prop | Description |
|---|---|
| digits($value) | Latin and Arabic-Indic digits to Persian. |
| latinDigits($value) | Persian and Arabic-Indic digits back to Latin. |
| number($value, $decimals = 0) | Persian digits with the ٬ and ٫ separators. |
| money($amount, $currency = null, $decimals = 0) | Formatted amount plus its currency label. Always Persian — it backs @toman; use mds:price for config-aware output. |
| currencyLabel($currency, $persian = null) | The label for a currency identifier — تومان/ریال, or Toman/Rial when Persian output is off; unknown values pass through as literals. |
| fileSize($bytes, $persianDigits = null) | Byte count: ۱۵۹ کیلوبایت, or 159 KB when Persian output is off. |
| ago($date, $persian = null) | A short relative phrase, past or future — ۳ ساعت پیش or 3 hours ago. |
| toDateTime($date) | Normalises a date-ish value into a DateTimeImmutable. |
MajidDs\Support\Jalali
| Prop | Description |
|---|---|
| format($date, $format, $persianDigits = null) | Formats a date in the Jalali calendar — Persian names and digits, or Latin digits with transliterated names (29 Mordad 1405) when Persian output is off. |
| fromGregorian($y, $m, $d) | Gregorian to Jalali, as [y, m, d]. |
| toGregorian($y, $m, $d) | Jalali to Gregorian, as [y, m, d]. |
| isLeapYear($year) | Whether a Jalali year is a leap year. |