src/Entity/Strategy.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\StrategyRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. /**
  8.  * @ORM\Entity(repositoryClass=StrategyRepository::class)
  9.  * @Vich\Uploadable
  10.  */
  11. class Strategy
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\Column(type="string", length=255, nullable=true)
  21.      */
  22.     private $title;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $description;
  27.     /**
  28.      * @var \DateTime
  29.      * @ORM\Column(type="datetime", nullable=true)
  30.      */
  31.     private $createdAt;
  32.     /**
  33.      * @var \DateTime
  34.      * @ORM\Column(type="datetime", nullable=true)
  35.      */
  36.     private $updatedAt;
  37.     /**
  38.      * @var \DateTime
  39.      * @ORM\Column(type="datetime", nullable=true)
  40.      */
  41.     private $deletedAt;
  42.     /**
  43.      * @ORM\Column(type="string", length=255, nullable=true)
  44.      */
  45.     private $image;
  46.     /**
  47.      * @Vich\UploadableField(mapping="strategies", fileNameProperty="image")
  48.      * @var File
  49.      */
  50.     private $imageFile;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity=Customer::class, inversedBy="strategies")
  53.      * @ORM\JoinColumn(nullable=false)
  54.      */
  55.     private $customer;
  56.     public function getId(): ?int
  57.     {
  58.         return $this->id;
  59.     }
  60.     public function getTitle(): ?string
  61.     {
  62.         return $this->title;
  63.     }
  64.     public function setTitle(?string $title): self
  65.     {
  66.         $this->title $title;
  67.         return $this;
  68.     }
  69.     public function getDescription(): ?string
  70.     {
  71.         return $this->description;
  72.     }
  73.     public function setDescription(string $description): self
  74.     {
  75.         $this->description $description;
  76.         return $this;
  77.     }
  78.     public function getCreatedAt(): ?\DateTimeInterface
  79.     {
  80.         return $this->createdAt;
  81.     }
  82.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  83.     {
  84.         $this->createdAt $createdAt;
  85.         return $this;
  86.     }
  87.     public function getUpdatedAt(): ?\DateTimeInterface
  88.     {
  89.         return $this->updatedAt;
  90.     }
  91.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  92.     {
  93.         $this->updatedAt $updatedAt;
  94.         return $this;
  95.     }
  96.     public function getDeletedAt(): ?\DateTimeInterface
  97.     {
  98.         return $this->deletedAt;
  99.     }
  100.     public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  101.     {
  102.         $this->deletedAt $deletedAt;
  103.         return $this;
  104.     }
  105.     public function getImage(): ?string
  106.     {
  107.         return $this->image;
  108.     }
  109.     public function setImage(?string $image): self
  110.     {
  111.         $this->image $image;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @param File|null $image
  116.      * @return Strategy
  117.      */
  118.     public function setImageFile(File $image null)
  119.     {
  120.         $this->imageFile $image;
  121.         if ($image) {
  122.             $this->updatedAt = new \DateTime('now');
  123.         }
  124.         return $this;
  125.     }
  126.     public function getImageFile()
  127.     {
  128.         return $this->imageFile;
  129.     }
  130.     public function getCustomer(): ?Customer
  131.     {
  132.         return $this->customer;
  133.     }
  134.     public function setCustomer(?Customer $customer): self
  135.     {
  136.         $this->customer $customer;
  137.         return $this;
  138.     }
  139.     public function __toArray($urlImages){
  140.         return [
  141.             'id' => $this->getId(),
  142.             'title' => $this->getTitle(),
  143.             'description' => $this->getDescription(),
  144.             'image' => $urlImages.$this->getImage(),
  145.         ];
  146.     }
  147. }