File: D:/HostingSpaces/SBogers10/centrum8a.komma.pro/app/KommaApp/Kms/Core/Attributes/Images.php
<?php
namespace App\KommaApp\Kms\Core\Attributes;
use App\KommaApp\Images\ImageService;
use App\KommaApp\Images\Models\Image;
use App\KommaApp\Kms\Core\Attributes\Models\AbstractImageProperty;
use App\KommaApp\Kms\Core\Attributes\Models\ImageProperty;
use App\KommaApp\Kms\Core\Attributes\Traits\LabelTrait;
use Illuminate\Database\Eloquent\Collection;
/**
* Class Image
* @package App\KommaApp\Kms\Core\Attributes
*/
class Images extends Attribute implements ImageableAttribute
{
use LabelTrait;
/** @var string $subFolder This is the subfolder of the path public/uploads/images where the images for this attribute wil be placed in*/
private $subFolder;
/** @var int $maxImages The maximum amount of images the attribute can hold*/
private $maxImages;
/**
* @var ImageProperty[] $imageSizes When you upload an image, the image will be processed and saved in the sizes you've specified with this variable
*/
private $imageSizes;
public function __construct()
{
$this->subFolder = '';
$this->imageSizes = [];
$this->maxImages = 0;
parent::__construct();
}
/**
* Returns a view that visually represents this attribute
*/
public function render()
{
$imageIds = explode('|' ,$this->value);
$images = Image::findMany($imageIds);
$view = \View::make('kms/attributes.images', [
'attribute' => $this,
'images' => $images
]);
return $view;
}
/**
* @return string
*/
public function getSubFolder(): string
{
return $this->subFolder;
}
/**
* @param string $subFolder
* @return Images
*/
public function setSubFolder(string $subFolder): Images
{
$this->subFolder = $subFolder;
return $this;
}
/**
* @return int
*/
public function getMaxImages(): int
{
return $this->maxImages;
}
/**
* @param int $maxImages
* @return Images
*/
public function setMaxImages(int $maxImages): Images
{
$this->maxImages = $maxImages;
return $this;
}
/**
* @return AbstractImageProperty[]
*/
public function getImageSizes(): array
{
return $this->imageSizes;
}
/**
* @param AbstractImageProperty[] $imageSizes
* @return Images
*/
public function setImageSizes(array $imageSizes): Images
{
$this->imageSizes = $imageSizes;
return $this;
}
/**
* @return string The value associated with the attribute
*/
public function getValue(): string
{
$value = json_encode($this->value);
return $value;
}
}