src/Entity/Assure.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AssureRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
  12. /**
  13.  * @ORM\Entity(repositoryClass=AssureRepository::class)
  14.  * @UniqueEntity("clientCode")
  15.  * @UniqueEntity("contractNumber")
  16.  */
  17. class Assure implements UserInterfacePasswordAuthenticatedUserInterface
  18. {
  19.     /**
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=255)
  27.      * @CrudField(label="Nom", index=true)
  28.      */
  29.     private $name;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      * @CrudField(label="Prénom", index=true)
  33.      */
  34.     private $firstname;
  35.     /**
  36.      * @ORM\Column(type="string", length=255, nullable=true)
  37.      * @CrudField(label="Adresse")
  38.      */
  39.     private $adress;
  40.     /**
  41.      * @ORM\Column(type="string", length=255, nullable=true)
  42.      * @CrudField(label="Code postal")
  43.      */
  44.     private $postalCode;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      * @CrudField(label="Ville")
  48.      */
  49.     private $city;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      * @CrudField(label="Portable")
  53.      */
  54.     private $mobilePhone;
  55.     /**
  56.      * @ORM\Column(type="string", length=255, nullable=true)
  57.      * @CrudField(label="Téléphone fixe")
  58.      */
  59.     private $fixedPhone;
  60.     /**
  61.      * @ORM\Column(type="string", length=255)
  62.      * @CrudField(label="Code client", index=true)
  63.      */
  64.     private $clientCode;
  65.     /**
  66.      * @ORM\Column(type="string", length=255)
  67.      * @CrudField(label="Numéro de contrat", index=true)
  68.      */
  69.     private $contractNumber;
  70.     /**
  71.      * @ORM\Column(type="string", length=14, nullable=true)
  72.      * @CrudField(label="SIRET")
  73.      */
  74.     private $siret;
  75.     /**
  76.      * @ORM\Column(type="string", length=255)
  77.      * @Assert\Email(message="L'adresse e-mail {{ value }} n'est pas une adresse email valide.")
  78.      * @CrudField(label="Email")
  79.      */
  80.     private $email;
  81.     /**
  82.      * @ORM\Column(type="string", length=255)
  83.      */
  84.     private $password;
  85.     /**
  86.      * @CrudField(label="Nouveau mot de passe")
  87.      */
  88.     private $newPassword;
  89.     /**
  90.      * @ORM\Column(type="json")
  91.      */
  92.     private $roles = ["ROLE_CLIENT"];
  93.     /**
  94.      * @ORM\Column(type="boolean", nullable=true)
  95.      * @CrudField(label="Compte validé", index=true)
  96.      */
  97.     private $activate;
  98.     /**
  99.      * @ORM\OneToMany(targetEntity=Document::class, mappedBy="client", orphanRemoval=true)
  100.      * @ORM\OrderBy({"date"="DESC"})
  101.      */
  102.     private $documents;
  103.     /**
  104.      * @ORM\OneToMany(targetEntity=Sinister::class, mappedBy="user")
  105.      */
  106.     private $sinisters;
  107.     public function __construct()
  108.     {
  109.         $this->documents = new ArrayCollection();
  110.         $this->sinisters = new ArrayCollection();
  111.     }
  112.     public function __toString(): string
  113.     {
  114.         return $this->getName() . " " $this->getFirstname() . " Code client: " $this->getClientCode() ?? $this->getId() ?? "N/A";
  115.     }
  116.     public function getId(): ?int
  117.     {
  118.         return $this->id;
  119.     }
  120.     public function getUsername(): ?string
  121.     {
  122.         return $this->clientCode;
  123.     }
  124.     public function getName(): ?string
  125.     {
  126.         return $this->name;
  127.     }
  128.     public function setName(string $name): self
  129.     {
  130.         $this->name $name;
  131.         return $this;
  132.     }
  133.     public function getFirstname(): ?string
  134.     {
  135.         return $this->firstname;
  136.     }
  137.     public function setFirstname(string $firstname): self
  138.     {
  139.         $this->firstname $firstname;
  140.         return $this;
  141.     }
  142.     public function getClientCode(): ?string
  143.     {
  144.         return $this->clientCode;
  145.     }
  146.     public function setClientCode(string $clientCode): self
  147.     {
  148.         $this->clientCode $clientCode;
  149.         return $this;
  150.     }
  151.     public function getContractNumber(): ?string
  152.     {
  153.         return $this->contractNumber;
  154.     }
  155.     public function setContractNumber(string $contractNumber): self
  156.     {
  157.         $this->contractNumber $contractNumber;
  158.         return $this;
  159.     }
  160.     public function getSiret(): ?string
  161.     {
  162.         return $this->siret;
  163.     }
  164.     public function setSiret(?string $siret): self
  165.     {
  166.         $this->siret $siret;
  167.         return $this;
  168.     }
  169.     public function getEmail(): ?string
  170.     {
  171.         return $this->email;
  172.     }
  173.     public function setEmail(string $email): self
  174.     {
  175.         $this->email $email;
  176.         return $this;
  177.     }
  178.     public function getPassword(): ?string
  179.     {
  180.         return $this->password;
  181.     }
  182.     public function setPassword(string $password): self
  183.     {
  184.         $this->password $password;
  185.         return $this;
  186.     }
  187.     public function getNewPassword(): ?string
  188.     {
  189.         return $this->newPassword;
  190.     }
  191.     public function setNewPassword(?string $password): self
  192.     {
  193.         $this->newPassword $password;
  194.         return $this;
  195.     }
  196.     /**
  197.      * @see UserInterface
  198.      */
  199.     public function getRoles(): array
  200.     {
  201.         $roles $this->roles;
  202.         // guarantee every user at least has ROLE_USER
  203.         $roles[] = 'ROLE_USER';
  204.         return array_unique($roles);
  205.     }
  206.     public function setRoles(array $roles): self
  207.     {
  208.         $this->roles $roles;
  209.         return $this;
  210.     }
  211.     /**
  212.      * A visual identifier that represents this user.
  213.      *
  214.      * @see UserInterface
  215.      */
  216.     public function getUserIdentifier(): string
  217.     {
  218.         return (string) $this->email;
  219.     }
  220.     /**
  221.      * Returning a salt is only needed, if you are not using a modern
  222.      * hashing algorithm (e.g. bcrypt or sodium) in your security.yaml.
  223.      *
  224.      * @see UserInterface
  225.      */
  226.     public function getSalt(): ?string
  227.     {
  228.         return null;
  229.     }
  230.     /**
  231.      * @see UserInterface
  232.      */
  233.     public function eraseCredentials()
  234.     {
  235.         // If you store any temporary, sensitive data on the user, clear it here
  236.         // $this->plainPassword = null;
  237.     }
  238.     public function isActivate(): ?bool
  239.     {
  240.         return $this->activate;
  241.     }
  242.     public function setActivate(?bool $activate): self
  243.     {
  244.         $this->activate $activate;
  245.         return $this;
  246.     }
  247.     /**
  248.      * @return Collection<int, Document>
  249.      */
  250.     public function getDocuments(): Collection
  251.     {
  252.         return $this->documents;
  253.     }
  254.     public function addDocument(Document $document): self
  255.     {
  256.         if (!$this->documents->contains($document)) {
  257.             $this->documents[] = $document;
  258.             $document->setClient($this);
  259.         }
  260.         return $this;
  261.     }
  262.     public function removeDocument(Document $document): self
  263.     {
  264.         if ($this->documents->removeElement($document)) {
  265.             // set the owning side to null (unless already changed)
  266.             if ($document->getClient() === $this) {
  267.                 $document->setClient(null);
  268.             }
  269.         }
  270.         return $this;
  271.     }
  272.     public function getAdress(): ?string
  273.     {
  274.         return $this->adress;
  275.     }
  276.     public function setAdress(?string $adress): self
  277.     {
  278.         $this->adress $adress;
  279.         return $this;
  280.     }
  281.     public function getPostalCode(): ?string
  282.     {
  283.         return $this->postalCode;
  284.     }
  285.     public function setPostalCode(?string $postalCode): self
  286.     {
  287.         $this->postalCode $postalCode;
  288.         return $this;
  289.     }
  290.     public function getCity(): ?string
  291.     {
  292.         return $this->city;
  293.     }
  294.     public function setCity(?string $city): self
  295.     {
  296.         $this->city $city;
  297.         return $this;
  298.     }
  299.     public function getMobilePhone(): ?string
  300.     {
  301.         return $this->mobilePhone;
  302.     }
  303.     public function setMobilePhone(?string $mobilePhone): self
  304.     {
  305.         $this->mobilePhone $mobilePhone;
  306.         return $this;
  307.     }
  308.     public function getFixedPhone(): ?string
  309.     {
  310.         return $this->fixedPhone;
  311.     }
  312.     public function setFixedPhone(string $fixedPhone): self
  313.     {
  314.         $this->fixedPhone $fixedPhone;
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return Collection<int, Sinister>
  319.      */
  320.     public function getSinisters(): Collection
  321.     {
  322.         return $this->sinisters;
  323.     }
  324.     public function addSinister(Sinister $sinister): self
  325.     {
  326.         if (!$this->sinisters->contains($sinister)) {
  327.             $this->sinisters[] = $sinister;
  328.             $sinister->setUser($this);
  329.         }
  330.         return $this;
  331.     }
  332.     public function removeSinister(Sinister $sinister): self
  333.     {
  334.         if ($this->sinisters->removeElement($sinister)) {
  335.             // set the owning side to null (unless already changed)
  336.             if ($sinister->getUser() === $this) {
  337.                 $sinister->setUser(null);
  338.             }
  339.         }
  340.         return $this;
  341.     }
  342. }