This package adds flexibility to work with Persian/Jalali dates in Laravel Nova resources. It provides two fields, PersianDate
and PersianDateTime
.
You may require this package using composer:
composer require aloko/nova-persian-datepicker
To use these fields, you add the following to your resource's fields()
method:
use Aloko\PersianDatepicker\PersianDate;
use Aloko\PersianDatepicker\PersianDateTime;
PersianDate::make('date_of_birth'), // For date fields
PersianDateTime::make('check_in') // For datetime fields
NOTE: Please don't forget to cast your date
and datetime
fields in your model class as explained in Attribute Casting in Laravel Docs, otherwise these fields will throw casting error.
Under the hood, this package uses the awesome Babakhani Datepicker library. Below screenshots are some samples of how this package works.
You can also select gregorian date using the same datepicker.
The datetime field will also have a time picker.
You can use format()
method as below to alter the way dates are displayed. Please note that format
string must match the standard explained in Babakhani Persian Date format docs.
PersianDate::make('date_of_birth')->format('YYYY-MM'), // This will only print year and month
PersianDateTime::make('check_in')->format('hh:mm') // This will only show hours and minutes
Below are items that needs to or will be improved in future.
- Better locale support
- Make it possible to accept almost all datepicker options available on PHP side for customization
- Reza Babakhani https://github.com/babakhani
The MIT License (MIT). Please see License File for more information.