src/Entity/Telegram/AgentPublicBot/BotCampaign.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Telegram\AgentPublicBot;
  3. use App\Entity\BaseEntity;
  4. use App\Repository\Telegram\AgentPublicBot\BotCampaignRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  9. #[ORM\Entity(repositoryClassBotCampaignRepository::class)]
  10. class BotCampaign extends BaseEntity
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\Column(type'guid'uniquetrue)]
  14.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  15.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  16.     private ?string $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $title null;
  19.     #[ORM\ManyToOne(inversedBy'botCampaigns')]
  20.     #[ORM\JoinColumn(nullablefalse)]
  21.     private ?Bot $bot null;
  22.     #[ORM\OneToMany(mappedBy'campaign'targetEntityBotUser::class)]
  23.     private Collection $botUsers;
  24.     public function __toString()
  25.     {
  26.         return $this->getTitle();
  27.     }
  28.     public function botUsersCount()
  29.     {
  30.         return count($this->botUsers);
  31.     }
  32.     public function __construct()
  33.     {
  34.         parent::__construct();
  35.         $this->botUsers = new ArrayCollection();
  36.     }
  37.     public function getId(): ?string
  38.     {
  39.         return $this->id;
  40.     }
  41.     public function getTitle(): ?string
  42.     {
  43.         return $this->title;
  44.     }
  45.     public function setTitle(string $title): static
  46.     {
  47.         $this->title $title;
  48.         return $this;
  49.     }
  50.     public function getBot(): ?Bot
  51.     {
  52.         return $this->bot;
  53.     }
  54.     public function setBot(?Bot $bot): static
  55.     {
  56.         $this->bot $bot;
  57.         return $this;
  58.     }
  59.     /**
  60.      * @return Collection<int, BotUser>
  61.      */
  62.     public function getBotUsers(): Collection
  63.     {
  64.         return $this->botUsers;
  65.     }
  66.     public function addBotUser(BotUser $botUser): static
  67.     {
  68.         if (!$this->botUsers->contains($botUser)) {
  69.             $this->botUsers->add($botUser);
  70.             $botUser->setCampaign($this);
  71.         }
  72.         return $this;
  73.     }
  74.     public function removeBotUser(BotUser $botUser): static
  75.     {
  76.         if ($this->botUsers->removeElement($botUser)) {
  77.             // set the owning side to null (unless already changed)
  78.             if ($botUser->getCampaign() === $this) {
  79.                 $botUser->setCampaign(null);
  80.             }
  81.         }
  82.         return $this;
  83.     }
  84. }