src/Flexy/ShopBundle/Entity/Resource/Agent.php line 19
<?php
namespace App\Flexy\ShopBundle\Entity\Resource;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Entity\User;
use App\Flexy\ShopBundle\Entity\Order\Order;
use App\Flexy\ShopBundle\Entity\Store\Store;
use App\Flexy\ShopBundle\Repository\Resource\AgentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Gedmo\Mapping\Annotation as Gedmo;
#[ApiResource]
#[ORM\Entity(repositoryClass: AgentRepository::class)]
#[Gedmo\SoftDeleteable(fieldName: 'deletedAt', timeAware: false, hardDelete: true)]
class Agent
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private ?string $firstName = null;
#[ORM\Column(type: 'string', length: 255)]
private ?string $lastName = null;
#[ORM\OneToOne(targetEntity: User::class, cascade: ['persist', 'remove'])]
#[Assert\Valid()]
private ?\App\Entity\User $user = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $email = null;
#[ORM\Column(type: 'string', length: 255)]
private ?string $phone = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $address = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $photoIdentity = null;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $gender = null;
#[ORM\OneToMany(targetEntity: Order::class, mappedBy: 'agent')]
private \Doctrine\Common\Collections\Collection|array $orders;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $identityNumber = null;
#[ORM\OneToMany(targetEntity: Order::class, mappedBy: 'agentToDo')]
private \Doctrine\Common\Collections\Collection|array $ordersToDolist;
#[ORM\ManyToOne(inversedBy: 'agents')]
private ?AgentType $agentType = null;
#[ORM\ManyToOne(inversedBy: 'agents')]
private ?Store $store = null;
#[ORM\ManyToOne(inversedBy: 'agent')]
private ?AgentObjective $agentObjective = null;
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $deletedAt = null;
public function __construct()
{
$this->orders = new ArrayCollection();
$this->user = new User();
$this->ordersToDolist = new ArrayCollection();
}
public function __toString()
{
return $this->firstName." ".$this->lastName." (".$this->getUser().")";
}
public function getId(): ?int
{
return $this->id;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(?string $address): self
{
$this->address = $address;
return $this;
}
public function getPhotoIdentity(): ?string
{
return $this->photoIdentity;
}
public function setPhotoIdentity(?string $photoIdentity): self
{
$this->photoIdentity = $photoIdentity;
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(?string $gender): self
{
$this->gender = $gender;
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrders(): Collection
{
return $this->orders;
}
public function addOrder(Order $order): self
{
if (!$this->orders->contains($order)) {
$this->orders[] = $order;
$order->setAgent($this);
}
return $this;
}
public function removeOrder(Order $order): self
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getAgent() === $this) {
$order->setAgent(null);
}
}
return $this;
}
public function getIdentityNumber(): ?string
{
return $this->identityNumber;
}
public function setIdentityNumber(?string $identityNumber): self
{
$this->identityNumber = $identityNumber;
return $this;
}
/**
* @return Collection<int, Order>
*/
public function getOrdersToDolist(): Collection
{
return $this->ordersToDolist;
}
public function addOrdersToDolist(Order $ordersToDolist): self
{
if (!$this->ordersToDolist->contains($ordersToDolist)) {
$this->ordersToDolist[] = $ordersToDolist;
$ordersToDolist->setAgentToDo($this);
}
return $this;
}
public function removeOrdersToDolist(Order $ordersToDolist): self
{
if ($this->ordersToDolist->removeElement($ordersToDolist)) {
// set the owning side to null (unless already changed)
if ($ordersToDolist->getAgentToDo() === $this) {
$ordersToDolist->setAgentToDo(null);
}
}
return $this;
}
public function getAgentType(): ?AgentType
{
return $this->agentType;
}
public function setAgentType(?AgentType $agentType): self
{
$this->agentType = $agentType;
return $this;
}
public function getStore(): ?Store
{
return $this->store;
}
public function setStore(?Store $store): self
{
$this->store = $store;
return $this;
}
public function getAgentObjective(): ?AgentObjective
{
return $this->agentObjective;
}
public function setAgentObjective(?AgentObjective $agentObjective): self
{
$this->agentObjective = $agentObjective;
return $this;
}
/**
* Get the value of deletedAt
*/
public function getDeletedAt()
{
return $this->deletedAt;
}
/**
* Set the value of deletedAt
*
* @return self
*/
public function setDeletedAt($deletedAt)
{
$this->deletedAt = $deletedAt;
return $this;
}
}