src/Flexy/ShopBundle/Entity/Resource/Agent.php line 26

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Resource;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  6. use App\Entity\User;
  7. use App\Flexy\ShopBundle\Entity\Customer\Complaint;
  8. use App\Flexy\ShopBundle\Entity\Order\Order;
  9. use App\Flexy\ShopBundle\Entity\Shipping\Vehicle\ShippingVehicle;
  10. use App\Flexy\ShopBundle\Entity\Store\Store;
  11. use App\Flexy\ShopBundle\Repository\Resource\AgentRepository;
  12. use Doctrine\Common\Collections\ArrayCollection;
  13. use Doctrine\Common\Collections\Collection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Symfony\Component\Serializer\Annotation\Groups;
  16. use Symfony\Component\Validator\Constraints as Assert;
  17. #[ApiResource(
  18.     normalizationContext: ['groups' => ['read','readPackEngagements']],
  19.     denormalizationContext: ['groups' => ['write']],
  20. )]
  21. #[ApiFilter(SearchFilter::class, properties: ['user.roles' => 'partial'])]
  22. #[ORM\Entity(repositoryClassAgentRepository::class)]
  23. class Agent
  24. {
  25.     #[ORM\Id]
  26.     #[ORM\GeneratedValue]
  27.     #[ORM\Column(type'integer')]
  28.     #[Groups(["read"])]
  29.     private $id;
  30.     #[Groups(["read","write"])]
  31.     #[ORM\Column(type'string'length255)]
  32.     private ?string $firstName null;
  33.     #[Groups(["read","write"])]
  34.     #[ORM\Column(type'string'length255)]
  35.     private ?string $lastName null;
  36.     #[ORM\OneToOne(targetEntityUser::class, cascade: ['persist''remove'])]
  37.     #[Assert\Valid()]
  38.     private ?\App\Entity\User $user null;
  39.     #[ORM\Column(type'string'length255nullabletrue)]
  40.     private ?string $email null;
  41.     #[ORM\Column(type'string'length255)]
  42.     private ?string $phone null;
  43.     #[ORM\Column(type'string'length255nullabletrue)]
  44.     private ?string $address null;
  45.     #[ORM\Column(type'string'length255nullabletrue)]
  46.     private ?string $photoIdentity null;
  47.     #[ORM\Column(type'string'length255nullabletrue)]
  48.     private ?string $gender null;
  49.     #[ORM\OneToMany(targetEntityOrder::class, mappedBy'agent')]
  50.     private \Doctrine\Common\Collections\Collection|array $orders;
  51.     #[ORM\Column(type'string'length255nullabletrue)]
  52.     private ?string $identityNumber null;
  53.     #[ORM\OneToMany(targetEntityOrder::class, mappedBy'agentToDo')]
  54.     private \Doctrine\Common\Collections\Collection|array $ordersToDolist;
  55.     #[ORM\ManyToOne(inversedBy'agents')]
  56.     private ?AgentType $agentType null;
  57.     #[ORM\ManyToOne(inversedBy'agents')]
  58.     private ?Store $store null;
  59.     #[ORM\OneToMany(mappedBy'agent'targetEntityComplaint::class)]
  60.     private Collection $complaints;
  61.     #[ORM\OneToOne(mappedBy'agentDriver'cascade: ['persist''remove'])]
  62.     private ?ShippingVehicle $shippingVehicle null;
  63.     #[ORM\Column(length255nullabletrue)]
  64.     private ?string $blindPassword null;
  65.     public function __construct()
  66.     {
  67.         $this->orders = new ArrayCollection();
  68.         $this->user = new User();
  69.         $this->ordersToDolist = new ArrayCollection();
  70.         $this->complaints = new ArrayCollection();
  71.     }
  72.     public function __toString()
  73.     {
  74.         return $this->firstName." ".$this->lastName." (".$this->getUser().")";
  75.     }
  76.     public function getId(): ?int
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function getFirstName(): ?string
  81.     {
  82.         return $this->firstName;
  83.     }
  84.     public function setFirstName(string $firstName): self
  85.     {
  86.         $this->firstName $firstName;
  87.         return $this;
  88.     }
  89.     public function getLastName(): ?string
  90.     {
  91.         return $this->lastName;
  92.     }
  93.     public function setLastName(string $lastName): self
  94.     {
  95.         $this->lastName $lastName;
  96.         return $this;
  97.     }
  98.     public function getUser(): ?User
  99.     {
  100.         return $this->user;
  101.     }
  102.     public function setUser(?User $user): self
  103.     {
  104.         $this->user $user;
  105.         return $this;
  106.     }
  107.     public function getEmail(): ?string
  108.     {
  109.         return $this->email;
  110.     }
  111.     public function setEmail(?string $email): self
  112.     {
  113.         $this->email $email;
  114.         return $this;
  115.     }
  116.     public function getPhone(): ?string
  117.     {
  118.         return $this->phone;
  119.     }
  120.     public function setPhone(string $phone): self
  121.     {
  122.         $this->phone $phone;
  123.         return $this;
  124.     }
  125.     public function getAddress(): ?string
  126.     {
  127.         return $this->address;
  128.     }
  129.     public function setAddress(?string $address): self
  130.     {
  131.         $this->address $address;
  132.         return $this;
  133.     }
  134.     public function getPhotoIdentity(): ?string
  135.     {
  136.         return $this->photoIdentity;
  137.     }
  138.     public function setPhotoIdentity(?string $photoIdentity): self
  139.     {
  140.         $this->photoIdentity $photoIdentity;
  141.         return $this;
  142.     }
  143.     public function getGender(): ?string
  144.     {
  145.         return $this->gender;
  146.     }
  147.     public function setGender(?string $gender): self
  148.     {
  149.         $this->gender $gender;
  150.         return $this;
  151.     }
  152.     /**
  153.      * @return Collection<int, Order>
  154.      */
  155.     public function getOrders(): Collection
  156.     {
  157.         return $this->orders;
  158.     }
  159.     public function addOrder(Order $order): self
  160.     {
  161.         if (!$this->orders->contains($order)) {
  162.             $this->orders[] = $order;
  163.             $order->setAgent($this);
  164.         }
  165.         return $this;
  166.     }
  167.     public function removeOrder(Order $order): self
  168.     {
  169.         if ($this->orders->removeElement($order)) {
  170.             // set the owning side to null (unless already changed)
  171.             if ($order->getAgent() === $this) {
  172.                 $order->setAgent(null);
  173.             }
  174.         }
  175.         return $this;
  176.     }
  177.     public function getIdentityNumber(): ?string
  178.     {
  179.         return $this->identityNumber;
  180.     }
  181.     public function setIdentityNumber(?string $identityNumber): self
  182.     {
  183.         $this->identityNumber $identityNumber;
  184.         return $this;
  185.     }
  186.     /**
  187.      * @return Collection<int, Order>
  188.      */
  189.     public function getOrdersToDolist(): Collection
  190.     {
  191.         return $this->ordersToDolist;
  192.     }
  193.     public function addOrdersToDolist(Order $ordersToDolist): self
  194.     {
  195.         if (!$this->ordersToDolist->contains($ordersToDolist)) {
  196.             $this->ordersToDolist[] = $ordersToDolist;
  197.             $ordersToDolist->setAgentToDo($this);
  198.         }
  199.         return $this;
  200.     }
  201.     public function removeOrdersToDolist(Order $ordersToDolist): self
  202.     {
  203.         if ($this->ordersToDolist->removeElement($ordersToDolist)) {
  204.             // set the owning side to null (unless already changed)
  205.             if ($ordersToDolist->getAgentToDo() === $this) {
  206.                 $ordersToDolist->setAgentToDo(null);
  207.             }
  208.         }
  209.         return $this;
  210.     }
  211.     public function getAgentType(): ?AgentType
  212.     {
  213.         return $this->agentType;
  214.     }
  215.     public function setAgentType(?AgentType $agentType): self
  216.     {
  217.         $this->agentType $agentType;
  218.         return $this;
  219.     }
  220.     public function getStore(): ?Store
  221.     {
  222.         return $this->store;
  223.     }
  224.     public function setStore(?Store $store): self
  225.     {
  226.         $this->store $store;
  227.         return $this;
  228.     }
  229.     /**
  230.      * @return Collection<int, Complaint>
  231.      */
  232.     public function getComplaints(): Collection
  233.     {
  234.         return $this->complaints;
  235.     }
  236.     public function addComplaint(Complaint $complaint): self
  237.     {
  238.         if (!$this->complaints->contains($complaint)) {
  239.             $this->complaints->add($complaint);
  240.             $complaint->setAgent($this);
  241.         }
  242.         return $this;
  243.     }
  244.  public function getShippingVehicle(): ?ShippingVehicle
  245.     {
  246.         return $this->shippingVehicle;
  247.     }
  248.     public function setShippingVehicle(?ShippingVehicle $shippingVehicle): self
  249.     {
  250.         // unset the owning side of the relation if necessary
  251.         if ($shippingVehicle === null && $this->shippingVehicle !== null) {
  252.             $this->shippingVehicle->setAgentDriver(null);
  253.         }
  254.         // set the owning side of the relation if necessary
  255.         if ($shippingVehicle !== null && $shippingVehicle->getAgentDriver() !== $this) {
  256.             $shippingVehicle->setAgentDriver($this);
  257.         }
  258.         $this->shippingVehicle $shippingVehicle;
  259.         return $this;
  260.     }
  261.     public function removeComplaint(Complaint $complaint): self
  262.     {
  263.         if ($this->complaints->removeElement($complaint)) {
  264.             // set the owning side to null (unless already changed)
  265.             if ($complaint->getAgent() === $this) {
  266.                 $complaint->setAgent(null);
  267.             }
  268.         }
  269.         return $this;
  270.     }
  271.  public function getBlindPassword(): ?string
  272.     {
  273.         return $this->blindPassword;
  274.     }
  275.     public function setBlindPassword(?string $blindPassword): self
  276.     {
  277.         $this->blindPassword $blindPassword;
  278.         return $this;
  279.     }
  280.     #[Groups(["read"])]
  281.     public function getFullName(): ?string
  282.     {
  283.         return $this->firstName." ".$this->lastName;
  284.     }
  285. }