File: D:/HostingSpaces/vanderkampen/kwaliteitsbouw.com/app/KommaApp/Kms/Core/Attributes/KmsLink.php
<?php
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
namespace App\KommaApp\Kms\Core\Attributes;
use View;
class KmsLink extends KmsAttribute
{
public $label;
public $buttonLabel;
public $link;
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->buttonLabel = $this->getOption('buttonLabel', $key);
$this->link = $this->generateLink($this->getOption('link', $key));
}
public function render()
{
return View::make('kms/attributes.link', [
'attribute' => $this
]);
}
protected function generateLink(array $link)
{
if( ! isset($link['params']) ) $link['params'] = [];
switch($link['type'])
{
case 'url':
return url($link['action'], $link['params']);
case 'action':
return action($link['action'], $link['params']);
case 'route':
return route($link['route'], $link['params']);
case 'asset':
return asset($link['action'], $link['params']);
}
return '';
}
}