src/Entity/AppAccount.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AppAccountRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  11. use Doctrine\ORM\Mapping\JoinColumn;
  12. #[ORM\Entity(repositoryClassAppAccountRepository::class)]
  13. #[ORM\Table(name'tb_app_accounts')]
  14. #[ORM\HasLifecycleCallbacks]
  15. #[UniqueEntity("username"message"Ce code client est déjà utilisé")]
  16. class AppAccount implements UserInterfacePasswordAuthenticatedUserInterface
  17. {
  18.     #[ORM\Id]
  19.     #[ORM\GeneratedValue]
  20.     #[ORM\Column(type"integer"uniquetrue)]
  21.     private ?int $id;
  22.     #[ORM\Column(type'string'length50nullablefalse)]
  23.     private ?string $code;
  24.     #[ORM\Column(type'string'length50nullablefalse)]
  25.     #[Assert\NotBlank(message"Saisir un code utilisateur")]
  26.     private ?string $username;
  27.     #[ORM\Column(type'string'length200nullablefalse)]
  28.     private ?string $password;
  29.     #[ORM\Column(type'boolean'nullabletrue)]
  30.     private ?bool $activated;
  31.     #[ORM\Column(type'string'length20nullablefalse)]
  32.     #[Assert\NotBlank(message"Le code client ne peut pas être vide")]
  33.     private ?string $clientCode;
  34.     #[ORM\Column(type'string'length100nullablefalse)]
  35.     #[Assert\NotBlank(message"Saisir le nom du client")]
  36.     private ?string $name;
  37.     #[ORM\Column(type'string'length20nullabletrue)]
  38.     #[Assert\NotBlank(message"Saisir un numéro de téléphone")]
  39.     #[Assert\Regex(pattern"/\d/"message"Le numéro de téléphone ne contient que des chiffres")]
  40.     private $phone;
  41.     #[ORM\Column(type'string'length50nullablefalse)]
  42.     #[Assert\Email(message"Saisir un email valide")]
  43.     private ?string $email;
  44.     #[ORM\Column(type'datetime'nullablefalse)]
  45.     private \DateTimeInterface $createdAt;
  46.     #[ORM\Column(type'datetime'nullablefalse)]
  47.     private ?\DateTimeInterface $modifiedAt;
  48.     #[ORM\ManyToOne(targetEntityUser::class)]
  49.     private ?User $createdBy;
  50.     #[ORM\ManyToOne(targetEntityCountry::class)]
  51.     #[Assert\NotBlank(message"Choisir le code pays")]
  52.     private ?Country $country;
  53.     #[ORM\Column(type'integer'nullablefalse)]
  54.     private ?int $step;
  55.     #[ORM\Column(type'boolean'nullablefalse)]
  56.     private bool $passwordSent;
  57.     #[ORM\ManyToMany(targetEntityModule::class)]
  58.     #[ORM\JoinTable(name'tb_app_accounts_modules')]
  59.     #[ORM\JoinColumn(name'app_account_id'referencedColumnName'id')]
  60.     #[ORM\InverseJoinColumn(name'modules_id'referencedColumnName'id')]
  61.     private Collection $modules;
  62.     #[ORM\Column(type'integer'nullabletrue)]
  63.     private int $nbLogin;
  64.     #[ORM\OneToMany(mappedBy'appAccount'targetEntityCompte::class, orphanRemovaltrue)]
  65.     private Collection $comptes;
  66.     #[ORM\OneToMany(mappedBy'appAccount'targetEntityClientDebit::class)]
  67.     private Collection $clientDebits;
  68.     #[ORM\OneToMany(mappedBy'accounts'targetEntityFrequentlyUsedAccount::class, orphanRemovaltrue)]
  69.     private Collection $frequentlyUsedAccounts;
  70.     #[ORM\OneToMany(mappedBy'appAccount'targetEntityLoginAttempt::class)]
  71.     private Collection $loginAttempts;
  72.     #[ORM\OneToMany(mappedBy'appAccount'targetEntityAppAccountNotification::class)]
  73.     private Collection $appAccountNotifications;
  74.     #[ORM\OneToMany(mappedBy'account'targetEntityTransactionAmountAccount::class)]
  75.     private Collection $transactionAmountAccounts;
  76.     public function __construct()
  77.     {
  78.         $this->createdAt = new \DateTime();
  79.         $this->passwordSent false;
  80.         $this->modules = new ArrayCollection();
  81.         $this->nbLogin 0;
  82.         $this->comptes = new ArrayCollection();
  83.         $this->clientDebits = new ArrayCollection();
  84.         $this->frequentlyUsedAccounts = new ArrayCollection();
  85.         $this->loginAttempts = new ArrayCollection();
  86.         $this->appAccountNotifications = new ArrayCollection();
  87.         $this->transactionAmountAccounts = new ArrayCollection();
  88.     }
  89.     public function getId(): ?int
  90.     {
  91.         return $this->id;
  92.     }
  93.     public function getCode(): ?string
  94.     {
  95.         return $this->code;
  96.     }
  97.     public function setCode(string $code): self
  98.     {
  99.         $this->code $code;
  100.         return $this;
  101.     }
  102.     public function getUsername(): ?string
  103.     {
  104.         return $this->username;
  105.     }
  106.     public function setUsername(string $username): self
  107.     {
  108.         $this->username $username;
  109.         return $this;
  110.     }
  111.     public function getPassword(): ?string
  112.     {
  113.         return $this->password;
  114.     }
  115.     public function setPassword(string $password): self
  116.     {
  117.         $this->password $password;
  118.         return $this;
  119.     }
  120.     public function getActivated(): ?bool
  121.     {
  122.         return $this->activated;
  123.     }
  124.     public function setActivated(?bool $activated): self
  125.     {
  126.         $this->activated $activated;
  127.         return $this;
  128.     }
  129.     public function getClientCode(): ?string
  130.     {
  131.         return $this->clientCode;
  132.     }
  133.     public function setClientCode(?string $clientCode): self
  134.     {
  135.         $this->clientCode $clientCode;
  136.         return $this;
  137.     }
  138.     public function getName(): ?string
  139.     {
  140.         return $this->name;
  141.     }
  142.     public function setName(?string $name): self
  143.     {
  144.         $this->name $name;
  145.         return $this;
  146.     }
  147.     public function getPhone(): ?string
  148.     {
  149.         return $this->phone;
  150.     }
  151.     public function setPhone(?string $phone): self
  152.     {
  153.         $this->phone $phone;
  154.         return $this;
  155.     }
  156.     public function getEmail(): ?string
  157.     {
  158.         return $this->email;
  159.     }
  160.     public function setEmail(?string $email): self
  161.     {
  162.         $this->email $email;
  163.         return $this;
  164.     }
  165.     public function getCreatedAt(): ?\DateTimeInterface
  166.     {
  167.         return $this->createdAt;
  168.     }
  169.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  170.     {
  171.         $this->createdAt $createdAt;
  172.         return $this;
  173.     }
  174.     public function getModifiedAt(): ?\DateTimeInterface
  175.     {
  176.         return $this->modifiedAt;
  177.     }
  178.     public function setModifiedAt(?\DateTimeInterface $modifiedAt): self
  179.     {
  180.         $this->modifiedAt $modifiedAt;
  181.         return $this;
  182.     }
  183.     public function getCreatedBy(): ?User
  184.     {
  185.         return $this->createdBy;
  186.     }
  187.     public function setCreatedBy(?User $createdBy): self
  188.     {
  189.         $this->createdBy $createdBy;
  190.         return $this;
  191.     }
  192.     public function getCountry(): ?Country
  193.     {
  194.         return $this->country;
  195.     }
  196.     public function setCountry(?Country $country): self
  197.     {
  198.         $this->country $country;
  199.         return $this;
  200.     }
  201.     public function getStep(): ?int
  202.     {
  203.         return $this->step;
  204.     }
  205.     public function setStep(?int $step): self
  206.     {
  207.         $this->step $step;
  208.         return $this;
  209.     }
  210.     /**
  211.      * @ORM\PreUpdate
  212.      */
  213.     public function onUpdate() {
  214.         $this->modifiedAt = new \DateTime();
  215.     }
  216.     public function getRoles()
  217.     {
  218.         // TODO: Implement getRoles() method.
  219.     }
  220.     public function getSalt()
  221.     {
  222.         // TODO: Implement getSalt() method.
  223.     }
  224.     public function eraseCredentials()
  225.     {
  226.         // TODO: Implement eraseCredentials() method.
  227.     }
  228.     public function getPasswordSent(): ?bool
  229.     {
  230.         return $this->passwordSent;
  231.     }
  232.     public function setPasswordSent(?bool $passwordSent): self
  233.     {
  234.         $this->passwordSent $passwordSent;
  235.         return $this;
  236.     }
  237.     /**
  238.      * @return Collection|Module[]
  239.      */
  240.     public function getModules(): Collection
  241.     {
  242.         return $this->modules;
  243.     }
  244.     public function addModule(Module $module): self
  245.     {
  246.         if (!$this->modules->contains($module)) {
  247.             $this->modules[] = $module;
  248.         }
  249.         return $this;
  250.     }
  251.     public function removeModule(Module $module): self
  252.     {
  253.         $this->modules->removeElement($module);
  254.         return $this;
  255.     }
  256.     public function getNbLogin(): ?int
  257.     {
  258.         return $this->nbLogin;
  259.     }
  260.     public function setNbLogin(?int $nbLogin): self
  261.     {
  262.         $this->nbLogin $nbLogin;
  263.         return $this;
  264.     }
  265.     /**
  266.      * @return Collection|Compte[]
  267.      */
  268.     public function getComptes(): Collection
  269.     {
  270.         return $this->comptes;
  271.     }
  272.     public function addCompte(Compte $compte): self
  273.     {
  274.         if (!$this->comptes->contains($compte)) {
  275.             $this->comptes[] = $compte;
  276.             $compte->setAppAccount($this);
  277.         }
  278.         return $this;
  279.     }
  280.     public function removeCompte(Compte $compte): self
  281.     {
  282.         if ($this->comptes->removeElement($compte)) {
  283.             // set the owning side to null (unless already changed)
  284.             if ($compte->getAppAccount() === $this) {
  285.                 $compte->setAppAccount(null);
  286.             }
  287.         }
  288.         return $this;
  289.     }
  290.     /**
  291.      * @return Collection|ClientDebit[]
  292.      */
  293.     public function getClientDebits(): Collection
  294.     {
  295.         return $this->clientDebits;
  296.     }
  297.     public function addClientDebit(ClientDebit $clientDebit): self
  298.     {
  299.         if (!$this->clientDebits->contains($clientDebit)) {
  300.             $this->clientDebits[] = $clientDebit;
  301.             $clientDebit->setAppAccount($this);
  302.         }
  303.         return $this;
  304.     }
  305.     public function removeClientDebit(ClientDebit $clientDebit): self
  306.     {
  307.         if ($this->clientDebits->removeElement($clientDebit)) {
  308.             // set the owning side to null (unless already changed)
  309.             if ($clientDebit->getAppAccount() === $this) {
  310.                 $clientDebit->setAppAccount(null);
  311.             }
  312.         }
  313.         return $this;
  314.     }
  315.     /**
  316.      * @return Collection|FrequentlyUsedAccount[]
  317.      */
  318.     public function getFrequentlyUsedAccounts(): Collection
  319.     {
  320.         return $this->frequentlyUsedAccounts;
  321.     }
  322.     public function addFrequentlyUsedAccount(FrequentlyUsedAccount $frequentlyUsedAccount): self
  323.     {
  324.         if (!$this->frequentlyUsedAccounts->contains($frequentlyUsedAccount)) {
  325.             $this->frequentlyUsedAccounts[] = $frequentlyUsedAccount;
  326.             $frequentlyUsedAccount->setAccount($this);
  327.         }
  328.         return $this;
  329.     }
  330.     public function removeFrequentlyUsedAccount(FrequentlyUsedAccount $frequentlyUsedAccount): self
  331.     {
  332.         if ($this->frequentlyUsedAccounts->removeElement($frequentlyUsedAccount)) {
  333.             // set the owning side to null (unless already changed)
  334.             if ($frequentlyUsedAccount->getAccount() === $this) {
  335.                 $frequentlyUsedAccount->setAccount(null);
  336.             }
  337.         }
  338.         return $this;
  339.     }
  340.     /**
  341.      * @return Collection<int, LoginAttempt>
  342.      */
  343.     public function getLoginAttempts(): Collection
  344.     {
  345.         return $this->loginAttempts;
  346.     }
  347.     public function addLoginAttempt(LoginAttempt $loginAttempt): static
  348.     {
  349.         if (!$this->loginAttempts->contains($loginAttempt)) {
  350.             $this->loginAttempts->add($loginAttempt);
  351.             $loginAttempt->setAppAccount($this);
  352.         }
  353.         return $this;
  354.     }
  355.     public function removeLoginAttempt(LoginAttempt $loginAttempt): static
  356.     {
  357.         if ($this->loginAttempts->removeElement($loginAttempt)) {
  358.             // set the owning side to null (unless already changed)
  359.             if ($loginAttempt->getAppAccount() === $this) {
  360.                 $loginAttempt->setAppAccount(null);
  361.             }
  362.         }
  363.         return $this;
  364.     }
  365.     /**
  366.      * @return Collection<int, AppAccountNotification>
  367.      */
  368.     public function getAppAccountNotifications(): Collection
  369.     {
  370.         return $this->appAccountNotifications;
  371.     }
  372.     public function addAppAccountNotification(AppAccountNotification $appAccountNotification): static
  373.     {
  374.         if (!$this->appAccountNotifications->contains($appAccountNotification)) {
  375.             $this->appAccountNotifications->add($appAccountNotification);
  376.             $appAccountNotification->setAppAccount($this);
  377.         }
  378.         return $this;
  379.     }
  380.     public function removeAppAccountNotification(AppAccountNotification $appAccountNotification): static
  381.     {
  382.         if ($this->appAccountNotifications->removeElement($appAccountNotification)) {
  383.             // set the owning side to null (unless already changed)
  384.             if ($appAccountNotification->getAppAccount() === $this) {
  385.                 $appAccountNotification->setAppAccount(null);
  386.             }
  387.         }
  388.         return $this;
  389.     }
  390.     /**
  391.      * @return Collection<int, TransactionAmountAccount>
  392.      */
  393.     public function getTransactionAmountAccounts(): Collection
  394.     {
  395.         return $this->transactionAmountAccounts;
  396.     }
  397.     public function addTransactionAmountAccount(TransactionAmountAccount $transactionAmountAccount): static
  398.     {
  399.         if (!$this->transactionAmountAccounts->contains($transactionAmountAccount)) {
  400.             $this->transactionAmountAccounts->add($transactionAmountAccount);
  401.             $transactionAmountAccount->setAccount($this);
  402.         }
  403.         return $this;
  404.     }
  405.     public function removeTransactionAmountAccount(TransactionAmountAccount $transactionAmountAccount): static
  406.     {
  407.         if ($this->transactionAmountAccounts->removeElement($transactionAmountAccount)) {
  408.             // set the owning side to null (unless already changed)
  409.             if ($transactionAmountAccount->getAccount() === $this) {
  410.                 $transactionAmountAccount->setAccount(null);
  411.             }
  412.         }
  413.         return $this;
  414.     }
  415.     public function __toString(): string
  416.     {
  417.         return $this->getClientCode()." - ".$this->getName();
  418.     }
  419. }