mziraki/nova-persian-datepicker

Persian Datepicker for Laravel Nova.


Keywords
date, nova, laravel, datetime, datepicker, persian
License
MIT

Documentation

Laravel Nova Persian Datepicker

Description

This package adds flexibility to work with Persian/Jalali dates in Laravel Nova resources. It provides two fields, PersianDate and PersianDateTime.

Installation and Usage

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.

How it Works

Under the hood, this package uses the awesome Babakhani Datepicker library. Below screenshots are some samples of how this package works.

Screenshots

Persian Date Field

You can also select gregorian date using the same datepicker.

Persian Date Time Field

The datetime field will also have a time picker.

Methods

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

To Do

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

Special Thanks

License

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