File: D:/HostingSpaces/SBogers10/lmbm.komma.pro/app/KommaApp/Kms/Core/Attributes/KmsDate.php
<?php
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
namespace App\KommaApp\Kms\Core\Attributes;
use Carbon\Carbon;
use View;
class KmsDate extends KmsAttribute{
public $label;
public $placeholder;
public $canNotChange;
function __construct($key, $value, array $options = [], array $errors = [], $siteId = null, $languageId = null, $section = null)
{
parent::__construct($key, $value, $options, $errors, $siteId, $languageId, $section);
$this->label = $this->getOption('label', $key);
$this->placeholder = $this->getOption('placeholder', $key);
$this->canNotChange = $this->getOption('canNotChange', false);
}
public function getValue($post = false)
{
if(!$this->value) return null;
return Carbon::parse($this->value);
}
public function dateForUiWidget()
{
if(! $this->value) return '';
$date = Carbon::parse($this->value);
if(! $date){
return '';
}
return $date->format('d-m-Y');
}
public function canNotChange()
{
return $this->section->getModelId() && $this->canNotChange;
}
public function render()
{
return View::make('kms/attributes.date', [
'attribute' => $this
]);
}
}