src/Flexy/ShopBundle/Entity/Resource/AgentType.php line 14

  1. <?php
  2. namespace App\Flexy\ShopBundle\Entity\Resource;
  3. use ApiPlatform\Metadata\ApiResource;
  4. use App\Repository\Flexy\ShopBundle\Entity\Resource\AgentTypeRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassAgentTypeRepository::class)]
  10. #[ApiResource]
  11. class AgentType
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(length255,unique:true)]
  20.     private ?string $code null;
  21.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  22.     private ?string $description null;
  23.     #[ORM\OneToMany(mappedBy'agentType'targetEntityAgent::class)]
  24.     private Collection $agents;
  25.     public function __construct()
  26.     {
  27.         $this->agents = new ArrayCollection();
  28.     }
  29.     public function __toString()
  30.     {
  31.         return (string)$this->name;
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName(): ?string
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName(string $name): self
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getCode(): ?string
  47.     {
  48.         return $this->code;
  49.     }
  50.     public function setCode(string $code): self
  51.     {
  52.         $this->code $code;
  53.         return $this;
  54.     }
  55.     public function getDescription(): ?string
  56.     {
  57.         return $this->description;
  58.     }
  59.     public function setDescription(?string $description): self
  60.     {
  61.         $this->description $description;
  62.         return $this;
  63.     }
  64.     /**
  65.      * @return Collection<int, Agent>
  66.      */
  67.     public function getAgents(): Collection
  68.     {
  69.         return $this->agents;
  70.     }
  71.     public function addAgent(Agent $agent): self
  72.     {
  73.         if (!$this->agents->contains($agent)) {
  74.             $this->agents->add($agent);
  75.             $agent->setAgentType($this);
  76.         }
  77.         return $this;
  78.     }
  79.     public function removeAgent(Agent $agent): self
  80.     {
  81.         if ($this->agents->removeElement($agent)) {
  82.             // set the owning side to null (unless already changed)
  83.             if ($agent->getAgentType() === $this) {
  84.                 $agent->setAgentType(null);
  85.             }
  86.         }
  87.         return $this;
  88.     }
  89. }