src/Entity/Organization.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrganizationRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use App\Entity\ServiceUsage;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. use App\Billing\Model\BillablePartyInterface;
  10. #[ORM\Entity(repositoryClassOrganizationRepository::class)]
  11. class Organization implements BillablePartyInterface
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     #[Assert\NotBlank(message"Le nom de l'organisation est obligatoire.")]
  19.     private ?string $nom null;
  20.     #[ORM\Column(length255nullabletrue)]
  21.     private ?string $matriculeFiscale null;
  22.     #[ORM\Column(length255nullabletrue)]
  23.     private ?string $adresse null;
  24.     #[ORM\Column(length255nullabletrue)]
  25.     private ?string $telephone null;
  26.     #[ORM\Column(length255nullabletrue)]
  27.     #[Assert\Email(message"L'email '{{ value }}' n'est pas un email valide.")]
  28.     private ?string $email null;
  29.     #[ORM\OneToMany(mappedBy'organization'targetEntityUser::class)]
  30.     private Collection $users;
  31.     #[ORM\OneToMany(mappedBy'organization'targetEntityServiceUsage::class)]
  32.     private Collection $serviceUsages;
  33.     public function __construct()
  34.     {
  35.         $this->users = new ArrayCollection();
  36.         $this->serviceUsages = new ArrayCollection();
  37.     }
  38.     public function getId(): ?int
  39.     {
  40.         return $this->id;
  41.     }
  42.     public function getNom(): ?string
  43.     {
  44.         return $this->nom;
  45.     }
  46.     public function setNom(string $nom): static
  47.     {
  48.         $this->nom $nom;
  49.         return $this;
  50.     }
  51.     public function getMatriculeFiscale(): ?string
  52.     {
  53.         return $this->matriculeFiscale;
  54.     }
  55.     public function setMatriculeFiscale(?string $matriculeFiscale): static
  56.     {
  57.         $this->matriculeFiscale $matriculeFiscale;
  58.         return $this;
  59.     }
  60.     public function getAdresse(): ?string
  61.     {
  62.         return $this->adresse;
  63.     }
  64.     public function setAdresse(?string $adresse): static
  65.     {
  66.         $this->adresse $adresse;
  67.         return $this;
  68.     }
  69.     public function getTelephone(): ?string
  70.     {
  71.         return $this->telephone;
  72.     }
  73.     public function setTelephone(?string $telephone): static
  74.     {
  75.         $this->telephone $telephone;
  76.         return $this;
  77.     }
  78.     public function getEmail(): ?string
  79.     {
  80.         return $this->email;
  81.     }
  82.     public function setEmail(?string $email): static
  83.     {
  84.         $this->email $email;
  85.         return $this;
  86.     }
  87.     /**
  88.      * @return Collection<int, User>
  89.      */
  90.     public function getUsers(): Collection
  91.     {
  92.         return $this->users;
  93.     }
  94.     public function addUser(User $user): static
  95.     {
  96.         if (!$this->users->contains($user)) {
  97.             $this->users->add($user);
  98.             $user->setOrganization($this);
  99.         }
  100.         return $this;
  101.     }
  102.     public function removeUser(User $user): static
  103.     {
  104.         if ($this->users->removeElement($user)) {
  105.             // set the owning side to null (unless already changed)
  106.             if ($user->getOrganization() === $this) {
  107.                 $user->setOrganization(null);
  108.             }
  109.         }
  110.         return $this;
  111.     }
  112.     public function __toString(): string
  113.     {
  114.         return $this->nom ?? '';
  115.     }
  116.     // BillablePartyInterface implementation
  117.     public function getBillingName(): string
  118.     {
  119.         return $this->nom;
  120.     }
  121.     public function getBillingAddress(): ?string
  122.     {
  123.         return $this->adresse;
  124.     }
  125.     public function getTaxId(): ?string
  126.     {
  127.         return $this->matriculeFiscale;
  128.     }
  129.     public function getBillingEmail(): ?string
  130.     {
  131.         return $this->email;
  132.     }
  133. }