src/Entity/Customer.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CustomerRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Symfony\Component\HttpFoundation\File\File;
  6. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  7. #[ORM\Entity(repositoryClassCustomerRepository::class)]
  8. #[Vich\Uploadable]
  9. class Customer
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length100uniquetrue)]
  16.     private ?string $name null;
  17.     #[ORM\Column(length100uniquetrue)]
  18.     private ?string $slug null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $description null;
  21.     #[ORM\Column(length255nullabletrue)]
  22.     private ?string $website null;
  23.     #[Vich\UploadableField(mapping'customer'fileNameProperty'imageName')]
  24.     private ?File $imageFile null;
  25.     #[ORM\Column(nullabletrue)]
  26.     private ?string $imageName null;
  27.     #[ORM\ManyToOne(inversedBy'customers')]
  28.     #[ORM\JoinColumn(nullablefalse)]
  29.     private ?Activity $activity null;
  30.     #[ORM\Column]
  31.     private ?\DateTimeImmutable $createdAt null;
  32.     #[ORM\Column(nullabletrue)]
  33.     private ?\DateTimeImmutable $updatedAt null;
  34.     #[ORM\ManyToOne(inversedBy'customers')]
  35.     private ?City $city null;
  36.     #[ORM\Column(length255nullabletrue)]
  37.     private ?string $email null;
  38.     #[ORM\Column(length18nullabletrue)]
  39.     private ?string $phone null;
  40.     public function __toString(): string
  41.     {
  42.         return $this->getName();
  43.     }
  44.     public function getId(): ?int
  45.     {
  46.         return $this->id;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     public function getSlug(): ?string
  58.     {
  59.         return $this->slug;
  60.     }
  61.     public function setSlug(string $slug): self
  62.     {
  63.         $this->slug $slug;
  64.         return $this;
  65.     }
  66.     public function getDescription(): ?string
  67.     {
  68.         return $this->description;
  69.     }
  70.     public function setDescription(?string $description): self
  71.     {
  72.         $this->description $description;
  73.         return $this;
  74.     }
  75.     public function getWebsite(): ?string
  76.     {
  77.         return $this->website;
  78.     }
  79.     public function setWebsite(?string $website): self
  80.     {
  81.         $this->website $website;
  82.         return $this;
  83.     }
  84.     /**
  85.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  86.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  87.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  88.      * must be able to accept an instance of 'File' as the bundle will inject one here
  89.      * during Doctrine hydration.
  90.      *
  91.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  92.      */
  93.     public function setImageFile(?File $imageFile null): void
  94.     {
  95.         $this->imageFile $imageFile;
  96.         if (null !== $imageFile) {
  97.             // It is required that at least one field changes if you are using doctrine
  98.             // otherwise the event listeners won't be called and the file is lost
  99.             $this->updatedAt = new \DateTimeImmutable();
  100.         }
  101.     }
  102.     public function getImageFile(): ?File
  103.     {
  104.         return $this->imageFile;
  105.     }
  106.     public function setImageName(?string $imageName): void
  107.     {
  108.         $this->imageName $imageName;
  109.     }
  110.     public function getImageName(): ?string
  111.     {
  112.         return $this->imageName;
  113.     }
  114.     public function getActivity(): ?Activity
  115.     {
  116.         return $this->activity;
  117.     }
  118.     public function setActivity(?Activity $activity): self
  119.     {
  120.         $this->activity $activity;
  121.         return $this;
  122.     }
  123.     public function getCreatedAt(): ?\DateTimeImmutable
  124.     {
  125.         return $this->createdAt;
  126.     }
  127.     public function setCreatedAt(\DateTimeImmutable $createdAt): self
  128.     {
  129.         $this->createdAt $createdAt;
  130.         return $this;
  131.     }
  132.     public function getUpdatedAt(): ?\DateTimeImmutable
  133.     {
  134.         return $this->updatedAt;
  135.     }
  136.     public function setUpdatedAt(?\DateTimeImmutable $updatedAt): self
  137.     {
  138.         $this->updatedAt $updatedAt;
  139.         return $this;
  140.     }
  141.     public function getCity(): ?City
  142.     {
  143.         return $this->city;
  144.     }
  145.     public function setCity(?City $city): self
  146.     {
  147.         $this->city $city;
  148.         return $this;
  149.     }
  150.     public function getEmail(): ?string
  151.     {
  152.         return $this->email;
  153.     }
  154.     public function setEmail(?string $email): self
  155.     {
  156.         $this->email $email;
  157.         return $this;
  158.     }
  159.     public function getPhone(): ?string
  160.     {
  161.         return $this->phone;
  162.     }
  163.     public function setPhone(?string $phone): self
  164.     {
  165.         $this->phone $phone;
  166.         return $this;
  167.     }
  168. }