<?php
namespace App\Entity;
use App\Repository\StrategyRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=StrategyRepository::class)
* @Vich\Uploadable
*/
class Strategy
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
*/
private $description;
/**
* @var \DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $createdAt;
/**
* @var \DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @var \DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $deletedAt;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @Vich\UploadableField(mapping="strategies", fileNameProperty="image")
* @var File
*/
private $imageFile;
/**
* @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="strategies")
* @ORM\JoinColumn(nullable=false)
*/
private $customer;
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 getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
/**
* @param File|null $image
* @return Strategy
*/
public function setImageFile(File $image = null)
{
$this->imageFile = $image;
if ($image) {
$this->updatedAt = new \DateTime('now');
}
return $this;
}
public function getImageFile()
{
return $this->imageFile;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
public function __toArray($urlImages){
return [
'id' => $this->getId(),
'title' => $this->getTitle(),
'description' => $this->getDescription(),
'image' => $urlImages.$this->getImage(),
];
}
}