File: D:/HostingSpaces/SBogers33/bbec.nl/workbench/komma/kms/src/Komma/Kms/Core/Attributes/KmsTable.php
<?php
/**
* Short description for the file.
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2015, Komma Mediadesign
*/
namespace Komma\Kms\Core\Attributes;
use View;
class KmsTable extends KmsAttribute{
public $label;
protected $relatedId;
protected $showTableHeaders = true;
protected $data = [];
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->setData($this->getOption('data', $key));
$this->relatedId = $this->getOption('relatedId', $key);
$this->showTableHeaders = $this->getOption('showTableHeaders', $key, true);
}
/**
* Get data from a repository
* @param $data
* @return array
*/
public function setData($data)
{
if(is_string($data))
{
$data = explode('@', $data);
$method = array_pop($data);
$class = $data[0];
$this->data = \App::make($class)->{$method}( $this->languageId, $this->relatedId);
return $this->data;
}
return $this->data = $data;
}
public function getData()
{
return $this->data;
}
/**
* Set the value for displaying
* @return mixed
*/
public function setValue($value)
{
$this->value = $value;
$this->setData($this->getOption('data', $this->getKey()));
return $value;
}
public function render()
{
return View::make('kms::attributes.table', [
'attribute' => $this
]);
}
}