z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.13k stars 2.81k forks source link

Add feature that we can use our Date system #1745

Closed alihastam closed 5 years ago

alihastam commented 6 years ago

Can you add this feature that we can use our Date system for example : https://github.com/morilog/jalali

tanks

alihastam commented 5 years ago

extension for jalali date PersianDate.php `<?php

namespace App\Admin\Extensions;

use Encore\Admin\Form\Field;

class PersianDate extends Field { protected $view = 'admin.pdate';

protected $prepend;

protected static $css = [
    '/css/persian-datepicker.css',
];

protected static $js = [
    '/js/persian-date.min.js',
    '/js/persian-datepicker.min.js',
];

public function render()
{

    $this->script = "$('{$this->getElementClassSelector()}').persianDatepicker({
        format: 'L',
        altFormat: 'llll',
         initialValue: false,
         'timePicker.enabled': true,
         initialValueType: 'persian'
    });";
    $this->prepend('<i class="fa fa-calendar"></i>')
        ->defaultAttribute('style', 'width: 110px');

    return parent::render();
}

public function prepend($string)
{
    if (is_null($this->prepend)) {
        $this->prepend = $string;
    }

    return $this;
}
protected function defaultAttribute($attribute, $value)
{
    if (!array_key_exists($attribute, $this->attributes)) {
        $this->attribute($attribute, $value);
    }

    return $this;
}

}`