src/Entity/User.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\UserRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  9. use Symfony\Component\Security\Core\User\UserInterface;
  10. #[ORM\Entity(repositoryClassUserRepository::class)]
  11. #[UniqueEntity(fields: ['email'], message'There is already an account with this email')]
  12. class User implements UserInterfacePasswordAuthenticatedUserInterface
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue]
  16.     #[ORM\Column(type'integer')]
  17.     private $id;
  18.     #[ORM\Column(type'string'length180uniquefalsenullabletrue)]
  19.     private $email;
  20.     #[ORM\Column(type'string'length180uniquefalsenullabletrue)]
  21.     private $phone;
  22.     #[ORM\Column(type'json')]
  23.     private $roles = [];
  24.     #[ORM\Column(type'string')]
  25.     private $password;
  26.     #[ORM\Column(type'string'nullabletrue)]
  27.     private $locale;
  28.     #[ORM\OneToMany(mappedBy'seller'targetEntitySales::class)]
  29.     private $sales;
  30.     #[ORM\Column(type'string'length255)]
  31.     private $username;
  32.     #[ORM\Column(type'string'length255)]
  33.     private $fullname;
  34.     #[ORM\OneToMany(mappedBy'seller'targetEntityInvoice::class)]
  35.     private Collection $invoices;
  36.     public function __construct()
  37.     {
  38.         $this->sales = new ArrayCollection();
  39.         $this->invoices = new ArrayCollection();
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getEmail(): ?string
  46.     {
  47.         return $this->email;
  48.     }
  49.     public function setEmail(string $email): self
  50.     {
  51.         $this->email $email;
  52.         return $this;
  53.     }
  54.     /**
  55.      * A visual identifier that represents this user.
  56.      *
  57.      * @see UserInterface
  58.      */
  59.     public function getUserIdentifier(): string
  60.     {
  61.         return (string) $this->email;
  62.     }
  63.     /**
  64.      * @see UserInterface
  65.      */
  66.     public function getRoles(): array
  67.     {
  68.         $roles $this->roles;
  69.         // guarantee every user at least has ROLE_USER
  70.         $roles[] = 'ROLE_USER';
  71.         return array_unique($roles);
  72.     }
  73.     public function setRoles(array $roles): self
  74.     {
  75.         $this->roles $roles;
  76.         return $this;
  77.     }
  78.     /**
  79.      * @see PasswordAuthenticatedUserInterface
  80.      */
  81.     public function getPassword(): string
  82.     {
  83.         return $this->password;
  84.     }
  85.     public function setPassword(string $password): self
  86.     {
  87.         $this->password $password;
  88.         return $this;
  89.     }
  90.     /**
  91.      * @see UserInterface
  92.      */
  93.     public function eraseCredentials()
  94.     {
  95.         // If you store any temporary, sensitive data on the user, clear it here
  96.         // $this->plainPassword = null;
  97.     }
  98.     public function getLocale(): ?string
  99.     {
  100.         return $this->locale;
  101.     }
  102.     public function setLocale(?string $locale): self
  103.     {
  104.         $this->locale $locale;
  105.         return $this;
  106.     }
  107.     /**
  108.      * @return Collection<int, Sales>
  109.      */
  110.     public function getSales(): Collection
  111.     {
  112.         return $this->sales;
  113.     }
  114.     public function addSale(Sales $sale): self
  115.     {
  116.         if (!$this->sales->contains($sale)) {
  117.             $this->sales[] = $sale;
  118.             $sale->setSeller($this);
  119.         }
  120.         return $this;
  121.     }
  122.     public function removeSale(Sales $sale): self
  123.     {
  124.         if ($this->sales->removeElement($sale)) {
  125.             // set the owning side to null (unless already changed)
  126.             if ($sale->getSeller() === $this) {
  127.                 $sale->setSeller(null);
  128.             }
  129.         }
  130.         return $this;
  131.     }
  132.     public function getUsername(): ?string
  133.     {
  134.         return $this->username;
  135.     }
  136.     public function setUsername(string $username): self
  137.     {
  138.         $this->username $username;
  139.         return $this;
  140.     }
  141.     public function getFullname(): ?string
  142.     {
  143.         return $this->fullname;
  144.     }
  145.     public function setFullname(string $fullname): self
  146.     {
  147.         $this->fullname $fullname;
  148.         return $this;
  149.     }
  150.     public function getInvoices(): Collection
  151.     {
  152.         return $this->invoices;
  153.     }
  154.     public function setInvoices(Collection $invoices): void
  155.     {
  156.         $this->invoices $invoices;
  157.     }
  158.     public function addInvoice(Invoice $invoice):self
  159.     {
  160.         if (!$this->invoices->contains($invoice)) {
  161.             $this->invoices->add($invoice);
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeInvoice(Invoice $invoice):self{
  166.         if($this->invoices->contains($invoice)){
  167.             $this->invoices->removeElement($invoice);
  168.         }
  169.         return $this;
  170.     }
  171.     /**
  172.      * @return mixed
  173.      */
  174.     public function getPhone()
  175.     {
  176.         return $this->phone;
  177.     }
  178.     /**
  179.      * @param mixed $phone
  180.      */
  181.     public function setPhone($phone): void
  182.     {
  183.         $this->phone $phone;
  184.     }
  185. }