for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Encore\Admin\Form\Field;
use Encore\Admin\Form\Field;
class DateRange extends Field
{
protected $format = 'YYYY-MM-DD';
public function __construct($column, $arguments)
$this->column['start'] = $column;
$this->column['end'] = $arguments[0];
array_shift($arguments);
$this->label = $this->formatLabel($arguments);
$this->id = $this->formatId($this->column);
$this->options(['format' => $this->format]);
}
public function prepare($value)
if ($value === '') {
$value = null;
return $value;
public function render()
$this->options['locale'] = config('app.locale');
$startOptions = json_encode($this->options);
$endOptions = json_encode($this->options + ['useCurrent' => false]);
$this->script = <<<EOT
$('#{$this->id['start']}').datetimepicker($startOptions);
$('#{$this->id['end']}').datetimepicker($endOptions);
$("#{$this->id['start']}").on("dp.change", function (e) {
$('#{$this->id['end']}').data("DateTimePicker").minDate(e.date);
});
$("#{$this->id['end']}").on("dp.change", function (e) {
$('#{$this->id['start']}').data("DateTimePicker").maxDate(e.date);
EOT;
return parent::render();