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

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