PHP code example of sghazanfari / filament-persian

1. Go to this page and download the library: Download sghazanfari/filament-persian library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sghazanfari / filament-persian example snippets


use Sghazanfari\FilamentPersian\FilamentPersianPlugin;
use Sghazanfari\FilamentPersian\Auth\Login;

public function panel(Panel $panel): Panel
{
    return $panel
        ->default()
        ->id('admin')
        ->path('admin')
        ->login(Login::class)
        ->plugin(FilamentPersianPlugin::make())
        ->font('Vazirmatn', ...)
        // ...
}

use Sghazanfari\FilamentPersian\Forms\Components\JalaliDatePicker;
use Sghazanfari\FilamentPersian\Forms\Components\IranianMobileInput;
use Sghazanfari\FilamentPersian\Forms\Components\PersianNumberInput;

JalaliDatePicker::make('delivery_date')
    ->label('تاریخ تحویل')
    ->withTime(),

IranianMobileInput::make('customer_mobile')
    ->label('موبایل مشتری'),

PersianNumberInput::make('total')
    ->label('مبلغ کل')
    ->money('IRT'),

use Sghazanfari\FilamentPersian\Tables\Columns\JalaliDateColumn;
use Sghazanfari\FilamentPersian\Tables\Columns\PersianMoneyColumn;
use Sghazanfari\FilamentPersian\Concerns\AutoJalaliDates;

class OrderResource extends Resource
{
    use AutoJalaliDates;

    public static function table(Table $table): Table
    {
        return static::autoJalaliDates(
            $table->columns([
                PersianTextColumn::make('order_number')->label('شماره'),
                PersianMoneyColumn::make('total')->label('مبلغ')->currency('IRT'),
            ])
        );
    }
}

use Sghazanfari\FilamentPersian\Widgets\PersianStatsWidget;

class DashboardStats extends PersianStatsWidget
{
    protected function getStats(): array
    {
        return [
            $this->makeNumberStat('کاربران', User::count()),
            $this->makeMoneyStat('درآمد', Order::sum('total')),
            $this->makeDateStat('امروز', now(), 'l j F Y'),
        ];
    }
}

use Sghazanfari\FilamentPersian\Concerns\HasPersianGlobalSearch;

class EventResource extends Resource
{
    use HasPersianGlobalSearch;

    public static function getGloballySearchableAttributes(): array
    {
        return ['title', 'body'];
    }
}

is_iran_holiday('2025-03-21');     // true
iran_holiday_names('2025-03-21');  // ['جشن نوروز', 'عید نوروز']
next_working_day(now());            // روز کاری بعدی

jalali_format(now(), 'Y/m/d H:i');   // ۱۴۰۳/۰۵/۱۲ ۱۴:۳۰
fa_number(1234567);                  // ۱٬۲۳۴٬۵۶۷
fa_money(48500000, 'IRT');           // ۴۸٬۵۰۰٬۰۰۰ تومان
is_valid_national_code('0084575948'); // true
detect_bank_from_card('6037997512345678'); // "بانک ملی ایران"

return [
    'locale' => 'fa',
    'direction' => 'rtl',
    'timezone' => 'Asia/Tehran',

    'font' => [
        'family' => 'Vazirmatn',
    ],

    'calendar' => [
        'type' => 'jalali',
        'digits' => 'persian',
    ],

    'numbers' => [
        'convert_in_ui' => true,
        'thousand_separator' => '٬',
        'decimal_separator' => '٫',
        'currency' => [
            'default' => 'IRT',
            'symbols' => [
                'IRT' => 'تومان',
                'IRR' => 'ریال',
            ],
        ],
    ],
];
bash
php artisan filament-persian:install
bash
php artisan filament-persian:seed-cities
bash
php artisan filament-persian:doctor
bash
# نصب و راه‌اندازی
php artisan filament-persian:install

# بررسی سلامت
php artisan filament-persian:doctor

# درج شهرهای ایران
php artisan filament-persian:seed-cities

# درج مجدد از صفر
php artisan filament-persian:seed-cities --fresh