src/Entity/User.php line 29

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use ApiPlatform\Core\Annotation\ApiSubresource;
  7. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  8. use App\Repository\UserRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\DBAL\Types\Types;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  14. use Symfony\Component\Security\Core\User\UserInterface;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Validator\Constraints\Email;
  17. use Symfony\Component\Validator\Constraints\Length;
  18. #[ORM\Entity(repositoryClassUserRepository::class)]
  19. #[ApiResource(
  20.     itemOperations: ['get' => [
  21.         'normalization_context' => ['groups' => ['read:User:collection''read:User:item''read:User']]
  22.     ]],
  23.     denormalizationContext: ['groups' => ['read:User:collection']],
  24.     normalizationContext: ['groups' => ['read:User:collection']]
  25. )]
  26. class User implements UserInterfacePasswordAuthenticatedUserInterface
  27. {
  28.     #[ORM\Id]
  29.     #[ORM\GeneratedValue]
  30.     #[ORM\Column]
  31.     #[Groups(['read:User:collection''read:User'])]
  32.     private ?int $id null;
  33.     #[ORM\Column(length180uniquetrue)]
  34.     #[
  35.         Groups(['read:User:collection''read:User']),
  36.         Email(message'Email Incorrect')
  37.     ]
  38.     private ?string $email null;
  39.     #[ORM\Column]
  40.     #[Groups(['read:User:collection'])]
  41.     private array $roles = [];
  42.     /**
  43.      * @var string The hashed password
  44.      */
  45.     #[ORM\Column]
  46.     #[
  47.         Groups(['read:User:collection']),
  48.         Length(min4),
  49.     ]
  50.     private ?string $password null;
  51.     #[ORM\OneToMany(mappedBy'patient'targetEntityPrescription::class)]
  52.     private Collection $prescriptions;
  53.     #[ORM\ManyToOne(inversedBy'pharmacy')]
  54.     private ?Subscription $subscription null;
  55.     #[ORM\OneToMany(mappedBy'patient'targetEntityOrder::class)]
  56.     private Collection $orders;
  57.     #[ORM\OneToMany(mappedBy'user'targetEntitySchedule::class)]
  58.     private Collection $schedules;
  59.     #[ORM\OneToMany(mappedBy'user'targetEntityService::class)]
  60.     private Collection $services;
  61.     #[ORM\OneToMany(mappedBy'pharmacy'targetEntityProduct::class, cascade: ["persist""remove"])]
  62.     //#[Groups(['user:write', 'user:read'])]
  63.     private Collection $products;
  64.     #[ORM\Column(length255)]
  65.     #[
  66.         Groups(['read:User:collection''read:User']),
  67.         Length(min3,minMessage'Nom trop court')
  68.     ]
  69.     private ?string $fullname null;
  70.     #[ORM\Column(length255nullabletrue)]
  71.     #[Groups(['read:User:collection''read:User'])]
  72.     private ?string $profil_url null;
  73.     #[ORM\Column(length255)]
  74.     #[
  75.         Groups(['read:User:collection''read:User']),
  76.         Length(min10,minMessage'trop court')
  77.     ]
  78.     private ?string $phone_number null;
  79.     #[ORM\Column(length255nullabletrue)]
  80.     #[Groups(['read:User:collection'])]
  81.     private ?string $site_web null;
  82.     #[ORM\Column(length255nullabletrue)]
  83.     #[Groups(['read:User:collection'])]
  84.     private ?string $tag_line null;
  85.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  86.     #[Groups(['read:User:item'])]
  87.     private ?string $description null;
  88.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  89.     #[Groups(['write:Speciality'])]
  90.     private ?Speciality $speciality null;
  91.     public function __construct()
  92.     {
  93.         $this->prescriptions = new ArrayCollection();
  94.         $this->orders = new ArrayCollection();
  95.         $this->schedules = new ArrayCollection();
  96.         $this->services = new ArrayCollection();
  97.         $this->products = new ArrayCollection();
  98.     }
  99.     public function getId(): ?int
  100.     {
  101.         return $this->id;
  102.     }
  103.     public function getEmail(): ?string
  104.     {
  105.         return $this->email;
  106.     }
  107.     public function setEmail(string $email): static
  108.     {
  109.         $this->email $email;
  110.         return $this;
  111.     }
  112.     /**
  113.      * A visual identifier that represents this user.
  114.      *
  115.      * @see UserInterface
  116.      */
  117.     public function getUserIdentifier(): string
  118.     {
  119.         return (string) $this->email;
  120.     }
  121.     /**
  122.      * @see UserInterface
  123.      */
  124.     public function getRoles(): array
  125.     {
  126.         $roles $this->roles;
  127.         // guarantee every user at least has ROLE_USER
  128.         $roles[] = 'ROLE_USER';
  129.         return array_unique($roles);
  130.     }
  131.     public function setRoles(array $roles): static
  132.     {
  133.         $this->roles $roles;
  134.         return $this;
  135.     }
  136.     /**
  137.      * @see PasswordAuthenticatedUserInterface
  138.      */
  139.     public function getPassword(): string
  140.     {
  141.         return $this->password;
  142.     }
  143.     public function setPassword(string $password): static
  144.     {
  145.         $this->password $password;
  146.         return $this;
  147.     }
  148.     /**
  149.      * @see UserInterface
  150.      */
  151.     public function eraseCredentials(): void
  152.     {
  153.         // If you store any temporary, sensitive data on the user, clear it here
  154.         // $this->plainPassword = null;
  155.     }
  156.     /**
  157.      * @return Collection<int, Prescription>
  158.      */
  159.     public function getPrescriptions(): Collection
  160.     {
  161.         return $this->prescriptions;
  162.     }
  163.     public function addPrescription(Prescription $prescription): static
  164.     {
  165.         if (!$this->prescriptions->contains($prescription)) {
  166.             $this->prescriptions->add($prescription);
  167.             $prescription->setPatient($this);
  168.         }
  169.         return $this;
  170.     }
  171.     public function removePrescription(Prescription $prescription): static
  172.     {
  173.         if ($this->prescriptions->removeElement($prescription)) {
  174.             // set the owning side to null (unless already changed)
  175.             if ($prescription->getPatient() === $this) {
  176.                 $prescription->setPatient(null);
  177.             }
  178.         }
  179.         return $this;
  180.     }
  181.     public function getSubscription(): ?Subscription
  182.     {
  183.         return $this->subscription;
  184.     }
  185.     public function setSubscription(?Subscription $subscription): static
  186.     {
  187.         $this->subscription $subscription;
  188.         return $this;
  189.     }
  190.     /**
  191.      * @return Collection<int, Order>
  192.      */
  193.     public function getOrders(): Collection
  194.     {
  195.         return $this->orders;
  196.     }
  197.     public function addOrder(Order $order): static
  198.     {
  199.         if (!$this->orders->contains($order)) {
  200.             $this->orders->add($order);
  201.             $order->setPatient($this);
  202.         }
  203.         return $this;
  204.     }
  205.     public function removeOrder(Order $order): static
  206.     {
  207.         if ($this->orders->removeElement($order)) {
  208.             // set the owning side to null (unless already changed)
  209.             if ($order->getPatient() === $this) {
  210.                 $order->setPatient(null);
  211.             }
  212.         }
  213.         return $this;
  214.     }
  215.     /**
  216.      * @return Collection<int, Schedule>
  217.      */
  218.     public function getSchedules(): Collection
  219.     {
  220.         return $this->schedules;
  221.     }
  222.     public function addSchedule(Schedule $schedule): static
  223.     {
  224.         if (!$this->schedules->contains($schedule)) {
  225.             $this->schedules->add($schedule);
  226.             $schedule->setUser($this);
  227.         }
  228.         return $this;
  229.     }
  230.     public function removeSchedule(Schedule $schedule): static
  231.     {
  232.         if ($this->schedules->removeElement($schedule)) {
  233.             // set the owning side to null (unless already changed)
  234.             if ($schedule->getUser() === $this) {
  235.                 $schedule->setUser(null);
  236.             }
  237.         }
  238.         return $this;
  239.     }
  240.     /**
  241.      * @return Collection<int, Service>
  242.      */
  243.     public function getServices(): Collection
  244.     {
  245.         return $this->services;
  246.     }
  247.     public function addService(Service $service): static
  248.     {
  249.         if (!$this->services->contains($service)) {
  250.             $this->services->add($service);
  251.             $service->setUser($this);
  252.         }
  253.         return $this;
  254.     }
  255.     public function removeService(Service $service): static
  256.     {
  257.         if ($this->services->removeElement($service)) {
  258.             // set the owning side to null (unless already changed)
  259.             if ($service->getUser() === $this) {
  260.                 $service->setUser(null);
  261.             }
  262.         }
  263.         return $this;
  264.     }
  265.     /**
  266.      * @return Collection<int, Product>
  267.      */
  268.     public function getProducts(): Collection
  269.     {
  270.         return $this->products;
  271.     }
  272.     public function addProduct(Product $product): static
  273.     {
  274.         if (!$this->products->contains($product)) {
  275.             $this->products->add($product);
  276.             $product->setPharmacy($this);
  277.         }
  278.         return $this;
  279.     }
  280.     public function removeProduct(Product $product): static
  281.     {
  282.         if ($this->products->removeElement($product)) {
  283.             // set the owning side to null (unless already changed)
  284.             if ($product->getPharmacy() === $this) {
  285.                 $product->setPharmacy(null);
  286.             }
  287.         }
  288.         return $this;
  289.     }
  290.     public function getFullname(): ?string
  291.     {
  292.         return $this->fullname;
  293.     }
  294.     public function setFullname(string $fullname): static
  295.     {
  296.         $this->fullname $fullname;
  297.         return $this;
  298.     }
  299.     public function getProfilUrl(): ?string
  300.     {
  301.         return $this->profil_url;
  302.     }
  303.     public function setProfilUrl(?string $profil_url): static
  304.     {
  305.         $this->profil_url $profil_url;
  306.         return $this;
  307.     }
  308.     public function getPhoneNumber(): ?string
  309.     {
  310.         return $this->phone_number;
  311.     }
  312.     public function setPhoneNumber(string $phone_number): static
  313.     {
  314.         $this->phone_number $phone_number;
  315.         return $this;
  316.     }
  317.     public function getSiteWeb(): ?string
  318.     {
  319.         return $this->site_web;
  320.     }
  321.     public function setSiteWeb(?string $site_web): static
  322.     {
  323.         $this->site_web $site_web;
  324.         return $this;
  325.     }
  326.     public function getTagLine(): ?string
  327.     {
  328.         return $this->tag_line;
  329.     }
  330.     public function setTagLine(?string $tag_line): static
  331.     {
  332.         $this->tag_line $tag_line;
  333.         return $this;
  334.     }
  335.     public function getDescription(): ?string
  336.     {
  337.         return $this->description;
  338.     }
  339.     public function setDescription(?string $description): static
  340.     {
  341.         $this->description $description;
  342.         return $this;
  343.     }
  344.     public function getSpeciality(): ?Speciality
  345.     {
  346.         return $this->speciality;
  347.     }
  348.     public function setSpeciality(?Speciality $speciality): static
  349.     {
  350.         $this->speciality $speciality;
  351.         return $this;
  352.     }
  353. }