File: D:/HostingSpaces/SBogers33/bbec.nl/workbench/komma/kms/src/Komma/Kms/Core/Attributes/KmsFileS.php
<?php
/**
* Short description for the file.
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Kms\Core\Attributes;
use Komma\Kms\Files\FileService;
use View;
class KmsFiles extends KmsAttribute{
public $label;
public $placeholder;
public $maxFiles;
public $subFolder;
public $accept;
protected $fileService;
function __construct($key, $value, array $options = [], array $errors = [], $languageId = null, $section = null)
{
parent::__construct($key, $value, $options, $errors, $languageId, $section);
$this->label = $this->getOption('label', $key);
$this->placeholder = $this->getOption('placeholder', $key);
$this->accept = $this->getOption('accept', $key);
$this->subFolder = $this->getOption('subFolder', null);
$this->maxFiles = $this->getOption('maxFiles', null);
$this->fileService = new FileService();
}
public function render()
{
// Todo: Check if this needs to be active
//$this->fileService->upload($this->value, $this->subFolder);
return View::make('kms::attributes.files', [
'attribute' => $this
]);
}
public function getValue()
{
return $this->value;
}
public function getValueAsJson(){
return $this->getValue() ? json_encode($this->getValue()) : '[]';
}
public function process()
{
$this->value = $this->fileService->upload($this->value, $this->subFolder);
}
public function delete()
{
$this->fileService->delete($this->value);
}
}