mziraki/nova-persian-datepicker

This package is abandoned and no longer maintained. No replacement package was suggested.

Persian Datepicker for Laravel Nova.

v0.1.5 2020-02-02 20:34 UTC

This package is auto-updated.

Last update: 2021-03-15 19:21:48 UTC


README

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

persian-date.png?raw=true

You can also select gregorian date using the same datepicker.

persian-date-in-en.png?raw=true

Persian Date Time Field

The datetime field will also have a time picker.

persian-datepicker.png?raw=true

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.