src/Entity/Sms/DeliveryList.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Sms;
  3. use App\Doctrine\Generator\DeliveryListIdGenerator;
  4. use App\Entity\MiniAbstractBase;
  5. use App\Entity\Traits\CreatedAtTrait;
  6. use App\Entity\Traits\NameTrait;
  7. use App\Entity\Traits\UpdatedAtTrait;
  8. use App\Repository\Sms\DeliveryListRepository;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. /**
  13.  * @ORM\Table(name="vulco_delivery_list")
  14.  *
  15.  * @ORM\Entity(repositoryClass=DeliveryListRepository::class)
  16.  */
  17. class DeliveryList
  18. {
  19.     use CreatedAtTrait;
  20.     use NameTrait;
  21.     use UpdatedAtTrait;
  22.     /**
  23.      * @ORM\Id
  24.      *
  25.      * @ORM\Column(type="delivery_list_id", length=255, nullable=false)
  26.      *
  27.      * @ORM\GeneratedValue(strategy="CUSTOM")
  28.      *
  29.      * @ORM\CustomIdGenerator(class=DeliveryListIdGenerator::class)
  30.      */
  31.     private string $id;
  32.     /**
  33.      * @ORM\Column(type="string", nullable=false)
  34.      */
  35.     private string $name;
  36.     /**
  37.      * @ORM\OneToMany(targetEntity="App\Entity\Sms\DeliveryContact", mappedBy="deliveryList", cascade={"persist"}, orphanRemoval=true)
  38.      *
  39.      * @ORM\OrderBy({"name": "ASC"})
  40.      */
  41.     private ?Collection $deliveryContacts;
  42.     public function __construct()
  43.     {
  44.         $this->deliveryContacts = new ArrayCollection();
  45.     }
  46.     public function getId(): string
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getDeliveryContacts(): ?Collection
  51.     {
  52.         return $this->deliveryContacts;
  53.     }
  54.     public function getDeliveryContactsAmount(): int
  55.     {
  56.         return count($this->getDeliveryContacts());
  57.     }
  58.     public function setDeliveryContacts(?Collection $deliveryContacts): self
  59.     {
  60.         $this->deliveryContacts $deliveryContacts;
  61.         return $this;
  62.     }
  63.     public function addDeliveryContact(DeliveryContact $deliveryContact): self
  64.     {
  65.         if (!$this->deliveryContacts->contains($deliveryContact)) {
  66.             $this->deliveryContacts->add($deliveryContact);
  67.             $deliveryContact->setDeliveryList($this);
  68.         }
  69.         return $this;
  70.     }
  71.     public function removeDeliveryContact(DeliveryContact $deliveryContact): self
  72.     {
  73.         if ($this->deliveryContacts->contains($deliveryContact)) {
  74.             $this->deliveryContacts->removeElement($deliveryContact);
  75.         }
  76.         return $this;
  77.     }
  78.     public function __toString(): string
  79.     {
  80.         return $this->id $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
  81.     }
  82. }