<?php
namespace App\Entity;
use App\Entity\Abstract\Persona;
use App\Repository\SellerRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Uid\Uuid;
#[ORM\Entity(repositoryClass: SellerRepository::class)]
class Seller extends Persona
{
#[ORM\OneToMany(mappedBy: 'seller', targetEntity: Enterprise::class)]
private Collection $enterprises;
#[ORM\ManyToOne(inversedBy: 'sellers')]
protected ?User $createdBy = null;
public function __construct()
{
$this->enterprises = new ArrayCollection();
}
/**
* @return Collection<int, Enterprise>
*/
public function getEnterprises(): Collection
{
return $this->enterprises;
}
public function addEnterprise(Enterprise $enterprise): self
{
if (!$this->enterprises->contains($enterprise)) {
$this->enterprises->add($enterprise);
$enterprise->setSeller($this);
}
return $this;
}
public function removeEnterprise(Enterprise $enterprise): self
{
if ($this->enterprises->removeElement($enterprise)) {
// set the owning side to null (unless already changed)
if ($enterprise->getSeller() === $this) {
$enterprise->setSeller(null);
}
}
return $this;
}
}