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/SBogers10/kommabasic.nl/vendor/komma/kms/src/Core/Attributes/Documents.php
<?php
namespace Komma\KMS\Core\Attributes;
use Komma\KMS\Core\Attributes\Interfaces\HasLabelInterface;
use Komma\KMS\Core\Attributes\Traits\ExplanationTrait;
use Komma\KMS\Documents\Models\Document;
use Komma\KMS\Core\Attributes\Models\AbstractImageProperty;
use Komma\KMS\Core\Attributes\Models\ImageProperty;
use Komma\KMS\Core\Attributes\Models\Traits\HasSubFoldersInterface;
use Komma\KMS\Core\Attributes\Models\Traits\SubFolderTrait;
use Komma\KMS\Core\Attributes\Traits\LabelTrait;

/**
 * Class Documents
 *
 * Note: the mapValueFrom reference value for this attribute can be anything as long as it is unique.
 *
 * @package App\Kms\Core\Attributes
 */
class Documents extends Attribute implements HasSubFoldersInterface, HasLabelInterface
{
    use LabelTrait;
    use SubFolderTrait;
    use ExplanationTrait;

    /** @var int $maxDocuments The maximum amount of documents the attribute can hold*/
    private int $maxDocuments;

    /**
     * @var ImageProperty[] $imageProperties When you upload an image, the image will be processed and saved in the sizes you've specified with this variable
     */
    private array $imageProperties = [];

    /** @var string $accept Which mime types to accept. Example: video/*,.jpeg */
    private string $accept;

    /**
     * @var string $extensionThumbsFolder The folder in which extension thumbs can be found. Relative to the document root
     */
    private string $extensionThumbsFolder = '/img/kms/extension_thumbs/';

    /**
     * @var bool $enablePreviewsIfPossible whether or not to show thumb previews if possible
     */
    private bool $enablePreviewsIfPossible = true;

    /**
     * @var bool $isSortable Whether or not the items are sortable
     */
    private bool $isSortable = true;

    /**
     * @var bool $largeDragAndDropArea Whether the drag and drop area is to big
     */
    private bool $largeDragAndDropArea = true;

    protected ?int $getsValueFrom = Attribute::ValueFromDocuments;

    /**
     * Returns a view that visually represents this attribute
     *
     * @return string
     * @throws \Throwable
     */
    public function render(): string
    {
        $view = view('KMS::attributes.documents', [
            'attribute' => $this,
            'imageProperties' => json_encode($this->imageProperties)
        ])->render();

        return $view;
    }

    /**
     * Gets the maximum amount of documents the document uploader can upload or null for unlimited
     *
     * @return int
     */
    public function getMaxDocuments(): ?int
    {
        return $this->maxDocuments;
    }

    /**
     * @param int $maxDocuments
     * @return Documents
     */
    public function setMaxDocuments(int $maxDocuments): Documents
    {
        $this->maxDocuments = $maxDocuments;
        return $this;
    }

    /**
     * @return string
     */
    public function getAccept(): string
    {
        return $this->accept ?? '';
    }

    /**
     * @param string $accept
     * @return Documents
     */
    public function setAccept(string $accept): Documents
    {
        $this->accept = $accept;
        return $this;
    }

    /**
     * @return AbstractImageProperty[]
     */
    public function getImageProperties(): array
    {
        return $this->imageProperties;
    }

    /**
     * @param AbstractImageProperty[] $imageProperties
     * @return Documents
     */
    public function setImageProperties(array $imageProperties): Documents
    {
        $this->imageProperties = $imageProperties;
        return $this;
    }

    /**
     * @return string
     */
    public function getExtensionThumbsFolder(): string
    {
        return $this->extensionThumbsFolder;
    }

    /**
     * @param string $extensionThumbsFolder
     * @return Documents
     */
    public function setExtensionThumbsFolder(string $extensionThumbsFolder): Documents
    {
        $this->extensionThumbsFolder = $extensionThumbsFolder;
        return $this;
    }

    /**
     * @return bool
     */
    public function getEnablePreviewsIfPossible(): bool
    {
        return $this->enablePreviewsIfPossible;
    }

    /**
     * @param bool $enablePreviewsIfPossible
     * @return Documents
     */
    public function setEnablePreviewsIfPossible(bool $enablePreviewsIfPossible): Documents
    {
        $this->enablePreviewsIfPossible = $enablePreviewsIfPossible;
        return $this;
    }

    /**
     * @return bool
     */
    public function getIsSortable(): bool
    {
        return $this->isSortable;
    }

    /**
     * @param bool $isSortable
     * @return Documents
     */
    public function setIsSortable(bool $isSortable): Documents
    {
        $this->isSortable = $isSortable;
        return $this;
    }

    /**
     * @return bool
     */
    public function hasSmallDragAndDropArea(): bool
    {
        return !$this->largeDragAndDropArea;
    }

    /**
     * @return Documents
     */
    public function setSmallDragAndDropArea(): Documents
    {
        $this->largeDragAndDropArea = false;
        return $this;
    }

    /**
     * @return Documents
     */
    public function onlyAllowImages(): Documents
    {
        return $this->setAccept('image/*');
    }

    /**
     * @param $value
     * @param $key
     * @return mixed
     */
    public function prepareValueForViewComponent($value, $key)
    {
        return Document::where('key', $key)->get();
    }
}