src/Entity/Seller.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Abstract\Persona;
  4. use App\Repository\SellerRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Security\Core\User\UserInterface;
  9. use Symfony\Component\Uid\Uuid;
  10. #[ORM\Entity(repositoryClass: SellerRepository::class)]
  11. class Seller extends Persona
  12. {
  13. #[ORM\OneToMany(mappedBy: 'seller', targetEntity: Enterprise::class)]
  14. private Collection $enterprises;
  15. #[ORM\ManyToOne(inversedBy: 'sellers')]
  16. protected ?User $createdBy = null;
  17. public function __construct()
  18. {
  19. $this->enterprises = new ArrayCollection();
  20. }
  21. /**
  22. * @return Collection<int, Enterprise>
  23. */
  24. public function getEnterprises(): Collection
  25. {
  26. return $this->enterprises;
  27. }
  28. public function addEnterprise(Enterprise $enterprise): self
  29. {
  30. if (!$this->enterprises->contains($enterprise)) {
  31. $this->enterprises->add($enterprise);
  32. $enterprise->setSeller($this);
  33. }
  34. return $this;
  35. }
  36. public function removeEnterprise(Enterprise $enterprise): self
  37. {
  38. if ($this->enterprises->removeElement($enterprise)) {
  39. // set the owning side to null (unless already changed)
  40. if ($enterprise->getSeller() === $this) {
  41. $enterprise->setSeller(null);
  42. }
  43. }
  44. return $this;
  45. }
  46. }