| Install | |
|---|---|
composer require zenepay/filament-buddhist-date-picker |
|
| Latest Version: | 4.0.0 |
| PHP: | >=8.2 |
This package adds buddhistEra support to filament v4 DatePicker and DateTimePicker.
https://filamentphp.com/docs/4.x/forms/fields/date-time-picker
For Filament 3: you may use version 1.x For Filament 4: you may use version 4.x Anyway, it should automatically identify using composer You can install the package via composer:
composer require zenepay/filament-buddhist-date-picker
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
DatePicker::make('start_date')->buddhist();
DateTimePicker::make('start_date')->buddhist();
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
DatePicker::make('start_at')->buddhist(false);
DatetimePicker::make('start_at')->buddhist(false);
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
DatePicker::make('birth_date')->buddhist(onlyLocales:['th','en']);
DateTimePicker::make('birth_date')->buddhist(onlyLocales:['th','en']);
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
DatePicker::make('start_at')->buddhist(lyLocales:on['th','en'],weekdaysMin:true);
DatetimePicker::make('start_at')->buddhist(onlyLocales:['th','en'],weekdaysMin:true);
You can also use this way
use Zenepay\FilamentBuddhistDatePicker\BuddhistDatePicker;
BuddhistDatePicker::make('start_date');
BuddhistDatePicker::make('birth_date')->onlyLocales(['th','en'])->weekdaysMin(false);
Or make alias to DatePicker and replace use Filament\Forms\Components\DatePicker to use Zenepay\FilamentBuddhistDatePicker\BuddhistDatePicker as DatePicker
//use Filament\Forms\Components\DatePicker -->
use Zenepay\FilamentBuddhistDatePicker\BuddhistDatePicker as DatePicker;
DatePicker::make('start_date');
DatePicker::make('birth_date')->onlyLocales(['th','en'])->weekdaysMin(false);
For Datetime format with AM PM 12H, which was available at https://github.com/filamentphp/filament/pull/6441, now it can be combined with Buddhist Era as optional.
use Filament\Forms\Components\DateTimePicker;
DatetimePicker::make('start_at')->hourMode(12)->displayFormat('d/m/y h:i A')->seconds(false); // 15/02/24 11:10 PM
This can be done by replace $table->date() with $table->buddhistDate() for dateTime replace with $table->buddhistDateTime()
TextColumn::make('start_at')->buddhistDate(format:'m/d/Y',onlyLocales:['th']); // 15/02/2567
### 6. If your project use the same format you may just set at AppServiceProvider
```php
public function boot(): void
{
DatePicker::configureUsing(function (DatePicker $datePicker) {
$datePicker->firstDayOfWeek(0);
$datePicker->buddhist('th');
});
}
## Test
./vendor/bin/pest ./tests
## Demo & Show Case
- [Water Billing](https://zoploen.com/demo/meterbill/office)
- user login: demo@example.com
- password: demo1234
## Credits
- [zenepay](https://github.com/zenepay)
- [All Contributors](https://github.com/zenepay/filament-buddhist-date-picker/blob/HEAD/contributors)
## License
The MIT License (MIT)
# Filament DatePicker และ DateTimePicker Extension สำหรับ calendar ภาษาไทย และ ปี พุทธศักราช
ใช้สำหรับ Larvavel 10 และ 11 Filament v3 `DatePicker` `DateTimePicker`.
## การติดตั้ง
รัน composer ที่ root ไดเร็กทอรีของ Laravel
```bash
composer require zenepay/filament-buddhist-date-picker
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
DatePicker::make('start_date')->buddhist();
DateTimePicker::make('start_date')->buddhist();
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
DatePicker::make('birth_date')->buddhist(onlyLocales:['th','en']);
DateTimePicker::make('birth_date')->buddhist(onlyLocales:['th','en']);
\Filament\Forms\Components\DatePicker::make('birth_date')->buddhist(onlyLocales:['th','en']);
\Filament\Forms\Components\DateTimePicker::make('birth_date')->buddhist(onlyLocales:['th','en']);
ให้เซ็ต weekdaysMin เป็น true หรือให้เป็นแบบสั้น อาทิตย์ จันทร์ อังคาร ให้เซ็ต เป็น false
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\DateTimePicker;
DatePicker::make('start_at')->buddhist(onlyLocales:['th','en'],weekdaysMin:true);
DatetimePicker::make('start_at')->buddhist(onlyLocales:['th','en'],weekdaysMin:true);
หรือใช้แบบ เป็น component ใหม่แทนเลย ก็ใช้แบบนี้ได้
use Zenepay\FilamentBuddhistDatePicker\BuddhistDatePicker;
BuddhistDatePicker::make('start_date');
BuddhistDatePicker::make('birth_date')->onlyLocales(['th','en'])->weekdaysMin(false);
หรือเปลี่ยน การใช้ use Filament\Forms\Components\DatePicker เป็น ใช้ use Zenepay\FilamentBuddhistDatePicker\BuddhistDatePicker as DatePicker แทน เพื่อไม่ต้องไล่แก้ ใส่ buddhist() แต่ละ DatePicker component ในหน้านั้น
//use Filament\Forms\Components\DatePicker -->
use Zenepay\FilamentBuddhistDatePicker\BuddhistDatePicker as DatePicker;
DatePicker::make('start_date');
DatePicker::make('birth_date')->onlyLocales(['th','en'])->weekdaysMin(false);
ถ้าต้องการแบบ AM PM 12H, ตามนี้ https://github.com/filamentphp/filament/pull/6441, สามารถตั้งค่าได้เช่นกัน.
use Filament\Forms\Components\DateTimePicker;
DatetimePicker::make('start_at')->hourMode(12)->displayFormat('d/m/y h:i A')->seconds(false); // 15/02/24 11:10 PM
เพียงเปลี่ยน date() เป็น buddhistDate() หรือ dateTime() เป็น buddhistDateTime()
TextColumn::make('start_at')->buddhistDate(format:'m/d/Y',onlyLocales:['th']); // 15/02/2567
### 6. ถ้าในโปรเจ็กท์ใช้เหมือนกันหมด ก็ทำใน AppServiceProvider ได้เลย แล้วทุก DatePicker ก็จะเป็น พศ เหมือนกัน**
```php
public function boot(): void
{
DatePicker::configureUsing(function (DatePicker $datePicker) {
$datePicker->firstDayOfWeek(0);
$datePicker->buddhist('th');
});
}
## Test
./vendor/bin/pest ./tests
## Demo & Show Case
- [Water Billing](https://demo.zoploen.com/meterbill)
- user login: demo@example.com
- password: demo1234
## Credits
- [zenepay](https://github.com/zenepay)
- [All Contributors](https://github.com/zenepay/filament-buddhist-date-picker/blob/HEAD/contributors)
## License
The MIT License (MIT)