format($format); } catch (\Exception $e) { return $date->format($format); } } return $date->format($format); } } if (!function_exists('persian_num')) { function persian_num($number) { $persian = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']; $english = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; return str_replace($english, $persian, (string) $number); } } if (!function_exists('format_currency')) { function format_currency($amount, $currency = 'IRR') { $formatted = number_format((float) $amount, $currency === 'IRR' ? 0 : 2); if (app()->getLocale() === 'fa') { $formatted = persian_num($formatted); } $symbol = ''; switch ($currency) { case 'IRR': $symbol = 'ریال'; break; case 'USD': $symbol = '$'; break; case 'EUR': $symbol = '€'; break; case 'AED': $symbol = 'د.إ'; break; } return $formatted . ' ' . $symbol; } } if (!function_exists('get_direction')) { function get_direction() { return app()->getLocale() === 'fa' ? 'rtl' : 'ltr'; } } if (!function_exists('is_rtl')) { function is_rtl() { return app()->getLocale() === 'fa'; } }