src/Entity/Establishment.php line 30

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use App\DoctrineExtensions\Timestampable\Traits\UserTimestampableEntity;
  5. use App\DoctrineExtensions\SoftDeleteable\Traits\UserSoftDeleteableEntity;
  6. use App\Repository\EstablishmentRepository;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  12. use Symfony\Component\Uid\Uuid;
  13. /**
  14.  * @ORM\Entity(repositoryClass=EstablishmentRepository::class)
  15.  * @ORM\Table(name="establishment", indexes={
  16.  *  @ORM\Index(name="name", columns={"name"}),
  17.  *  @ORM\Index(name="reference", columns={"reference"}),
  18.  *  @ORM\Index(name="postcode", columns={"postcode"}),
  19.  *  @ORM\Index(name="email", columns={"email"}),
  20.  *  @ORM\Index(name="deleted_at", columns={"deleted_at"}),
  21.  *  @ORM\Index(name="created_at", columns={"created_at"}),
  22.  *  @ORM\Index(name="updated_at", columns={"updated_at"})
  23.  * })
  24.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
  25.  */
  26. class Establishment
  27. {
  28.     use UserTimestampableEntity;
  29.     use UserSoftDeleteableEntity;
  30.     /**
  31.      * @ORM\Id
  32.      * @ORM\Column(type="uuid")
  33.      * @ORM\GeneratedValue(strategy="CUSTOM")
  34.      * @ORM\CustomIdGenerator(class=UuidGenerator::class)
  35.      */
  36.     private ?Uuid $id null;
  37.     /**
  38.      * @ORM\Column(type="string", length=128)
  39.      */
  40.     private string $name;
  41.     /**
  42.      * @ORM\Column(type="string", length=128, nullable=true)
  43.      */
  44.     private ?string $reference null;
  45.     /**
  46.      * @ORM\Column(type="string", length=128, nullable=true)
  47.      */
  48.     private ?string $address null;
  49.     /**
  50.      * @ORM\Column(type="string", length=128, nullable=true)
  51.      */
  52.     private ?string $address2 null;
  53.     /**
  54.      * @ORM\Column(type="string", length=32, nullable=true)
  55.      */
  56.     private ?string $postcode null;
  57.     /**
  58.      * @ORM\Column(type="string", length=128, nullable=true)
  59.      */
  60.     private ?string $city null;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity=Country::class, inversedBy="establishments")
  63.      */
  64.     private Country $country;
  65.     /**
  66.      * @ORM\Column(type="string", length=32, nullable=true)
  67.      */
  68.     private ?string $phone null;
  69.     /**
  70.      * @ORM\Column(type="string", length=255, nullable=true)
  71.      */
  72.     private ?string $email null;
  73.     /**
  74.      * @ORM\ManyToOne(targetEntity=Context::class, inversedBy="establishments")
  75.      * @ORM\JoinColumn(nullable=false)
  76.      */
  77.     private Context $context;
  78.     /**
  79.      * @ORM\OneToMany(targetEntity=UsersEstablishments::class, mappedBy="establishment")
  80.      */
  81.     private Collection $usersEstablishments;
  82.     public function __construct()
  83.     {
  84.         $this->usersEstablishments = new ArrayCollection();
  85.     }
  86.     public function getId(): ?Uuid
  87.     {
  88.         return $this->id;
  89.     }
  90.     public function getName(): ?string
  91.     {
  92.         return $this->name;
  93.     }
  94.     public function setName(string $name): self
  95.     {
  96.         $this->name $name;
  97.         return $this;
  98.     }
  99.     public function getReference(): ?string
  100.     {
  101.         return $this->reference;
  102.     }
  103.     public function setReference(?string $reference): self
  104.     {
  105.         $this->reference $reference;
  106.         return $this;
  107.     }
  108.     public function getAddress(): ?string
  109.     {
  110.         return $this->address;
  111.     }
  112.     public function setAddress(?string $address): self
  113.     {
  114.         $this->address $address;
  115.         return $this;
  116.     }
  117.     public function getAddress2(): ?string
  118.     {
  119.         return $this->address2;
  120.     }
  121.     public function setAddress2(?string $address2): self
  122.     {
  123.         $this->address2 $address2;
  124.         return $this;
  125.     }
  126.     public function getPostcode(): ?string
  127.     {
  128.         return $this->postcode;
  129.     }
  130.     public function setPostcode(?string $postcode): self
  131.     {
  132.         $this->postcode $postcode;
  133.         return $this;
  134.     }
  135.     public function getCity(): ?string
  136.     {
  137.         return $this->city;
  138.     }
  139.     public function setCity(?string $city): self
  140.     {
  141.         $this->city $city;
  142.         return $this;
  143.     }
  144.     public function getCountry(): ?Country
  145.     {
  146.         return $this->country;
  147.     }
  148.     public function setCountry(?Country $country): self
  149.     {
  150.         $this->country $country;
  151.         return $this;
  152.     }
  153.     public function getPhone(): ?string
  154.     {
  155.         return $this->phone;
  156.     }
  157.     public function setPhone(?string $phone): self
  158.     {
  159.         $this->phone $phone;
  160.         return $this;
  161.     }
  162.     public function getEmail(): ?string
  163.     {
  164.         return $this->email;
  165.     }
  166.     public function setEmail(?string $email): self
  167.     {
  168.         $this->email $email;
  169.         return $this;
  170.     }
  171.     public function getContext(): ?Context
  172.     {
  173.         return $this->context;
  174.     }
  175.     public function setContext(?Context $context): self
  176.     {
  177.         $this->context $context;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, UsersEstablishments>
  182.      */
  183.     public function getUsersEstablishments(): Collection
  184.     {
  185.         return $this->usersEstablishments;
  186.     }
  187.     public function addUsersEstablishment(UsersEstablishments $usersEstablishment): self
  188.     {
  189.         if (!$this->usersEstablishments->contains($usersEstablishment)) {
  190.             $this->usersEstablishments[] = $usersEstablishment;
  191.             $usersEstablishment->setEstablishment($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeUsersEstablishment(UsersEstablishments $usersEstablishment): self
  196.     {
  197.         if ($this->usersEstablishments->removeElement($usersEstablishment)) {
  198.             // set the owning side to null (unless already changed)
  199.             if ($usersEstablishment->getEstablishment() === $this) {
  200.                 $usersEstablishment->setEstablishment(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205. }