File: D:/HostingSpaces/slenders/slenders.nl/app/Komma/Kms/Core/Attributes/Video.php
<?php
namespace App\Komma\Kms\Core\Attributes;
use App\Komma\Kms\Core\Attributes\Traits\LabelTrait;
use App\Komma\Kms\Core\Attributes\Traits\PlaceholderTextTrait;
class Video extends Attribute
{
use LabelTrait;
/** @var bool Whether or not the video may automatically start playing */
private $autoPlay = false;
/**
* TextArea constructor.
* @param string $text The text of the TextArea
*/
public function __construct(string $text = 'Video')
{
$this->setLabelText($text);
parent::__construct();
}
/**
* Returns a view that visually represents this attribute
*
* @return \Illuminate\View\View
*/
public function render()
{
return view('kms/attributes.video', [
'attribute' => $this
]);
}
/**
* @return bool
*/
public function getAutoPlay(): bool
{
return $this->autoPlay;
}
/**
* @param bool $autoPlay
* @return Video
*/
public function setAutoPlay(bool $autoPlay): Video
{
$this->autoPlay = $autoPlay;
return $this;
}
public function prepareValueForViewComponent($value)
{
$explodedVideo = explode(',', $value);
if(sizeof($explodedVideo) == 1) return $value;
list($autoplay, $video_id) = $explodedVideo;
return collect(['autoplay' => $autoplay, 'video_id' => $video_id]);
}
}