src/Entity/Entreprise.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\EntrepriseRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=EntrepriseRepository::class)
  9.  */
  10. class Entreprise
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\Column(type="string", length=255)
  20.      */
  21.     private $RaisonSociale;
  22.     /**
  23.      * @ORM\Column(type="string", length=255, nullable=true)
  24.      */
  25.     private $Siret;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=true)
  28.      */
  29.     private $Naf;
  30.     /**
  31.      * @ORM\Column(type="string", length=255, nullable=true)
  32.      */
  33.     private $Adresse;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $Code_Insee;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $Statut;
  42.     /**
  43.      * @ORM\Column(type="json", nullable=true)
  44.      */
  45.     private $Utilisateur = [];
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $rcs;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private $num_voie;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $code_postal;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $commune;
  62.     /**
  63.      * @ORM\ManyToMany(targetEntity=User::class, mappedBy="entreprises")
  64.      */
  65.     private $users;
  66.     /**
  67.      * @ORM\OneToMany(targetEntity=Facture::class, mappedBy="entreprise")
  68.      */
  69.     private $factures;
  70.     public function __construct()
  71.     {
  72.         $this->users = new ArrayCollection();
  73.         $this->factures = new ArrayCollection();
  74.         $this->Utilisateur = [];
  75.     }
  76.     public function getId(): ?int
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function getRaisonSociale(): ?string
  81.     {
  82.         return $this->RaisonSociale;
  83.     }
  84.     public function setRaisonSociale(string $RaisonSociale): self
  85.     {
  86.         $this->RaisonSociale $RaisonSociale;
  87.         return $this;
  88.     }
  89.     public function getSiret(): ?string
  90.     {
  91.         return $this->Siret;
  92.     }
  93.     public function setSiret(?string $Siret): self
  94.     {
  95.         $this->Siret $Siret;
  96.         return $this;
  97.     }
  98.     public function getNaf(): ?string
  99.     {
  100.         return $this->Naf;
  101.     }
  102.     public function setNaf(?string $Naf): self
  103.     {
  104.         $this->Naf $Naf;
  105.         return $this;
  106.     }
  107.     public function getAdresse(): ?string
  108.     {
  109.         return $this->Adresse;
  110.     }
  111.     public function setAdresse(?string $Adresse): self
  112.     {
  113.         $this->Adresse $Adresse;
  114.         return $this;
  115.     }
  116.     public function getCodeInsee(): ?string
  117.     {
  118.         return $this->Code_Insee;
  119.     }
  120.     public function setCodeInsee(?string $Code_Insee): self
  121.     {
  122.         $this->Code_Insee $Code_Insee;
  123.         return $this;
  124.     }
  125.     public function getStatut(): ?string
  126.     {
  127.         return $this->Statut;
  128.     }
  129.     public function setStatut(?string $Statut): self
  130.     {
  131.         $this->Statut $Statut;
  132.         return $this;
  133.     }
  134.     /**
  135.      * @return array
  136.      */
  137.     public function getUtilisateur(): array
  138.     {
  139.         if ($this->Utilisateur === null) {
  140.             return [];
  141.         }
  142.         
  143.         // Handle case where value might be stored as JSON string
  144.         if (is_string($this->Utilisateur)) {
  145.             $decoded json_decode($this->Utilisateurtrue);
  146.             return is_array($decoded) ? $decoded : [];
  147.         }
  148.         
  149.         // Handle case where value might be a single integer
  150.         if (is_int($this->Utilisateur)) {
  151.             return [strval($this->Utilisateur)];
  152.         }
  153.         
  154.         // Handle case where value is already an array
  155.         if (is_array($this->Utilisateur)) {
  156.             return $this->Utilisateur;
  157.         }
  158.         
  159.         return [];
  160.     }
  161.     public function setUtilisateur(?array $Utilisateur): self
  162.     {
  163.         $this->Utilisateur $Utilisateur ?? [];
  164.         return $this;
  165.     }
  166.     public function addUtilisateur(string $userId): self
  167.     {
  168.         if (!is_array($this->Utilisateur)) {
  169.             $this->Utilisateur = [];
  170.         }
  171.         if (!in_array($userId$this->Utilisateur)) {
  172.             $this->Utilisateur[] = $userId;
  173.         }
  174.         return $this;
  175.     }
  176.     public function removeUtilisateur(string $userId): self
  177.     {
  178.         if (!is_array($this->Utilisateur)) {
  179.             return $this;
  180.         }
  181.         $this->Utilisateur array_filter($this->Utilisateur, function($id) use ($userId) {
  182.             return $id !== $userId;
  183.         });
  184.         return $this;
  185.     }
  186.     public function getRcs(): ?string
  187.     {
  188.         return $this->rcs;
  189.     }
  190.     public function setRcs(?string $rcs): self
  191.     {
  192.         $this->rcs $rcs;
  193.         return $this;
  194.     }
  195.     public function getNumVoie(): ?string
  196.     {
  197.         return $this->num_voie;
  198.     }
  199.     public function setNumVoie(?string $num_voie): self
  200.     {
  201.         $this->num_voie $num_voie;
  202.         return $this;
  203.     }
  204.     public function getCodePostal(): ?string
  205.     {
  206.         return $this->code_postal;
  207.     }
  208.     public function setCodePostal(?string $code_postal): self
  209.     {
  210.         $this->code_postal $code_postal;
  211.         return $this;
  212.     }
  213.     public function getCommune(): ?string
  214.     {
  215.         return $this->commune;
  216.     }
  217.     public function setCommune(?string $commune): self
  218.     {
  219.         $this->commune $commune;
  220.         return $this;
  221.     }
  222.     /**
  223.      * @return Collection|User[]
  224.      */
  225.     public function getUsers(): Collection
  226.     {
  227.         return $this->users;
  228.     }
  229.     public function addUser(User $user): self
  230.     {
  231.         if (!$this->users->contains($user)) {
  232.             $this->users[] = $user;
  233.             $user->addEntreprise($this);
  234.         }
  235.         return $this;
  236.     }
  237.     public function removeUser(User $user): self
  238.     {
  239.         if ($this->users->removeElement($user)) {
  240.             $user->removeEntreprise($this);
  241.         }
  242.         return $this;
  243.     }
  244.     /**
  245.      * @return Collection|Facture[]
  246.      */
  247.     public function getFactures(): Collection
  248.     {
  249.         return $this->factures;
  250.     }
  251.     public function addFacture(Facture $facture): self
  252.     {
  253.         if (!$this->factures->contains($facture)) {
  254.             $this->factures[] = $facture;
  255.             $facture->setEntreprise($this);
  256.         }
  257.         return $this;
  258.     }
  259.     public function removeFacture(Facture $facture): self
  260.     {
  261.         if ($this->factures->removeElement($facture)) {
  262.             // set the owning side to null (unless already changed)
  263.             if ($facture->getEntreprise() === $this) {
  264.                 $facture->setEntreprise(null);
  265.             }
  266.         }
  267.         return $this;
  268.     }
  269. }