src/Flexy/ShopBundle/Entity/Resource/AgentType.php line 14
<?php
namespace App\Flexy\ShopBundle\Entity\Resource;
use ApiPlatform\Metadata\ApiResource;
use App\Repository\Flexy\ShopBundle\Entity\Resource\AgentTypeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: AgentTypeRepository::class)]
#[ApiResource]
class AgentType
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255,unique:true)]
private ?string $code = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\OneToMany(mappedBy: 'agentType', targetEntity: Agent::class)]
private Collection $agents;
public function __construct()
{
$this->agents = new ArrayCollection();
}
public function __toString()
{
return (string)$this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection<int, Agent>
*/
public function getAgents(): Collection
{
return $this->agents;
}
public function addAgent(Agent $agent): self
{
if (!$this->agents->contains($agent)) {
$this->agents->add($agent);
$agent->setAgentType($this);
}
return $this;
}
public function removeAgent(Agent $agent): self
{
if ($this->agents->removeElement($agent)) {
// set the owning side to null (unless already changed)
if ($agent->getAgentType() === $this) {
$agent->setAgentType(null);
}
}
return $this;
}
}