HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/stafa/werkenbijstafa.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]);

    }
}