<?php
namespace App\Entity;
use App\Repository\ServiceProRepository;
use App\Traits\DateTrait;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=ServiceProRepository::class)
*
* @Serializer\ExclusionPolicy("ALL")
*
* @Vich\Uploadable
*/
class ServicePro
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose
* @Groups({"service_pro"})
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*
* @Expose
* @Groups({"service_pro"})
*/
private $title;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", length=12)
*
* @Expose
* @Groups({"service_pro"})
*/
private $value;
/**
* @ORM\Column(type="boolean")
*
* @Expose
* @Groups({"service_pro"})
*/
private $status;
use DateTrait;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
// Vich Uploader
/**
* @Vich\UploadableField(mapping="service_pro_images", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @ORM\OneToMany(targetEntity=ServiceProField::class, mappedBy="servicePro", orphanRemoval=true, cascade={"persist"})
*/
private $serviceProFields;
/**
* @ORM\Column(type="array")
*/
private array $contactEmails = [];
public function __construct()
{
$this->serviceProFields = new ArrayCollection();
}
public function getImageFile()
{
return $this->imageFile;
}
/**
* @param File $imageFile
*
* @return void
*/
public function setImageFile(File $imageFile): void
{
$this->imageFile = $imageFile;
if (NULL !== $imageFile) {
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new DateTime();
}
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
public function isStatus(): ?bool
{
return $this->status;
}
public function setStatus(bool $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, ServiceProField>
*/
public function getServiceProFields(): Collection
{
return $this->serviceProFields;
}
public function addServiceProField(ServiceProField $serviceProField): self
{
if (!$this->serviceProFields->contains($serviceProField)) {
$this->serviceProFields[] = $serviceProField;
$serviceProField->setServicePro($this);
}
return $this;
}
public function removeServiceProField(ServiceProField $serviceProField): self
{
if ($this->serviceProFields->removeElement($serviceProField)) {
// set the owning side to null (unless already changed)
if ($serviceProField->getServicePro() === $this) {
$serviceProField->setServicePro(NULL);
}
}
return $this;
}
public function getContactEmails(): ?array
{
return $this->contactEmails;
}
public function setContactEmails(array $contactEmails): self
{
$this->contactEmails = $contactEmails;
return $this;
}
}