File: D:/HostingSpaces/SBogers10/meulendijk.komma.pro/app/KommaApp/Kms/Core/Attributes/KmsRoute.php
<?php
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
namespace App\KommaApp\Kms\Core\Attributes;
use App\KommaApp\Languages\Models\Language;
use View;
class KmsRoute extends KmsAttribute
{
public $label;
public $placeholder;
public $structure;
public $slugField;
public $parentField;
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->structure = $this->getOption('structure', $key);
$this->slugField = $this->getOption('slugField', $key);
$this->parentField = $this->getOption('parentField', null);
}
public function getValidation()
{
$validation = $this->getOption('validation');
return $validation;
}
public function render()
{
$this->parseStructure();
return View::make('kms/attributes.route', [
'attribute' => $this
]);
}
public function parseStructure()
{
$this->structure = str_replace('[[languageSlug]]', $this->getLanguageSlug($this->languageId), $this->structure);
$this->structure = str_replace('[[parentSlugs]]', 'parent/parent', $this->structure);
$this->structure = str_replace('[[slug]]', $this->slugField, $this->structure);
}
protected function getLanguageSlug($languageId)
{
if ($languageId != null) return Language::find($languageId)->iso_2;
return '';
}
}