<?php
namespace App\Entity;
use App\Repository\EntrepriseRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=EntrepriseRepository::class)
*/
class Entreprise
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $RaisonSociale;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $Siret;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $Naf;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $Adresse;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $Code_Insee;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $Statut;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $Utilisateur = [];
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $rcs;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $num_voie;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $code_postal;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $commune;
/**
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="entreprises")
*/
private $users;
/**
* @ORM\OneToMany(targetEntity=Facture::class, mappedBy="entreprise")
*/
private $factures;
public function __construct()
{
$this->users = new ArrayCollection();
$this->factures = new ArrayCollection();
$this->Utilisateur = [];
}
public function getId(): ?int
{
return $this->id;
}
public function getRaisonSociale(): ?string
{
return $this->RaisonSociale;
}
public function setRaisonSociale(string $RaisonSociale): self
{
$this->RaisonSociale = $RaisonSociale;
return $this;
}
public function getSiret(): ?string
{
return $this->Siret;
}
public function setSiret(?string $Siret): self
{
$this->Siret = $Siret;
return $this;
}
public function getNaf(): ?string
{
return $this->Naf;
}
public function setNaf(?string $Naf): self
{
$this->Naf = $Naf;
return $this;
}
public function getAdresse(): ?string
{
return $this->Adresse;
}
public function setAdresse(?string $Adresse): self
{
$this->Adresse = $Adresse;
return $this;
}
public function getCodeInsee(): ?string
{
return $this->Code_Insee;
}
public function setCodeInsee(?string $Code_Insee): self
{
$this->Code_Insee = $Code_Insee;
return $this;
}
public function getStatut(): ?string
{
return $this->Statut;
}
public function setStatut(?string $Statut): self
{
$this->Statut = $Statut;
return $this;
}
/**
* @return array
*/
public function getUtilisateur(): array
{
if ($this->Utilisateur === null) {
return [];
}
// Handle case where value might be stored as JSON string
if (is_string($this->Utilisateur)) {
$decoded = json_decode($this->Utilisateur, true);
return is_array($decoded) ? $decoded : [];
}
// Handle case where value might be a single integer
if (is_int($this->Utilisateur)) {
return [strval($this->Utilisateur)];
}
// Handle case where value is already an array
if (is_array($this->Utilisateur)) {
return $this->Utilisateur;
}
return [];
}
public function setUtilisateur(?array $Utilisateur): self
{
$this->Utilisateur = $Utilisateur ?? [];
return $this;
}
public function addUtilisateur(string $userId): self
{
if (!is_array($this->Utilisateur)) {
$this->Utilisateur = [];
}
if (!in_array($userId, $this->Utilisateur)) {
$this->Utilisateur[] = $userId;
}
return $this;
}
public function removeUtilisateur(string $userId): self
{
if (!is_array($this->Utilisateur)) {
return $this;
}
$this->Utilisateur = array_filter($this->Utilisateur, function($id) use ($userId) {
return $id !== $userId;
});
return $this;
}
public function getRcs(): ?string
{
return $this->rcs;
}
public function setRcs(?string $rcs): self
{
$this->rcs = $rcs;
return $this;
}
public function getNumVoie(): ?string
{
return $this->num_voie;
}
public function setNumVoie(?string $num_voie): self
{
$this->num_voie = $num_voie;
return $this;
}
public function getCodePostal(): ?string
{
return $this->code_postal;
}
public function setCodePostal(?string $code_postal): self
{
$this->code_postal = $code_postal;
return $this;
}
public function getCommune(): ?string
{
return $this->commune;
}
public function setCommune(?string $commune): self
{
$this->commune = $commune;
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addEntreprise($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
$user->removeEntreprise($this);
}
return $this;
}
/**
* @return Collection|Facture[]
*/
public function getFactures(): Collection
{
return $this->factures;
}
public function addFacture(Facture $facture): self
{
if (!$this->factures->contains($facture)) {
$this->factures[] = $facture;
$facture->setEntreprise($this);
}
return $this;
}
public function removeFacture(Facture $facture): self
{
if ($this->factures->removeElement($facture)) {
// set the owning side to null (unless already changed)
if ($facture->getEntreprise() === $this) {
$facture->setEntreprise(null);
}
}
return $this;
}
}