shalior/filament-persian-date-field

A FilamentPhp form field to pick persian dates

v2.0.0 2024-01-06 21:01 UTC

README

Latest Version on Packagist Total Downloads

filament-demo

Installation

You can install the package via composer:

composer require shalior/filament-persian-date-field

To use with filament v2 use version ^1

You can publish the config file with:

php artisan vendor:publish --tag="filament-persian-date-field-config"

Usage

You'll use this component with Filament forms.

It syncs the related gregorian date (as string: Y-m-d) with your LiveWire component. Use the field like any other filament form fields:

    protected function getFormSchema(): array
    {
        return [
            \Shalior\FilamentPersianDateField\Components\PersianDatePicker::make('persianDate')
            ->id('persian-date')
            ->maxDate(now()->format('Y-m-d'))
            ->minDate(now()->subWeek()->format('Y-m-d'))
            ->withoutTime()
            ->viewMode('month') // accepts 'day', 'month', 'year'
            ->default('2022-04-28'),
        ];
    }

Persian date table column

You can use this field as a column in your table:

The column assumes you've installed verta or morilog/jalali if neither of them is installed, it will use Carbon's translatedFormat()

    Shalior\FilamentPersianDateField\Columns::make('created_at')
        ->translateLabel()
        ->format('Y/m/d') // default is 'H:i:s Y/m/d'
        ->timeZone('Asia/Tehran'), // default is 'Asia/Tehran'
        // renders as: ۱۳۹۹/۰۸/۰۱ in the table

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

I Encourage you to do so.

Credits

License

The MIT License (MIT). Please see License File for more information.