src/Entity/Website/Campaign.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Website;
  3. use App\Entity\Generic\Customer\Customer;
  4. use App\Entity\Website\Website\Website;
  5. use App\Repository\Website\CampaignRepository;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
  10. use App\Entity\BaseEntity;
  11. #[ORM\Entity(repositoryClassCampaignRepository::class)]
  12. class Campaign extends BaseEntity
  13. {
  14.     #[ORM\Id]
  15.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  16.     #[ORM\CustomIdGenerator(class: UuidGenerator::class)]
  17.     #[ORM\Column(type'guid'uniquetrue)]
  18.     private ?string $id null;
  19.     #[ORM\Column(length255)]
  20.     private ?string $slug null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $name null;
  23.     #[ORM\Column(nullabletrue)]
  24.     private ?int $count null;
  25.     #[ORM\Column(nullabletrue)]
  26.     private ?int $views null;
  27.     #[ORM\OneToMany(mappedBy'campaign'targetEntityCustomer::class)]
  28.     private Collection $customers;
  29.     #[ORM\ManyToOne(inversedBy'campaigns')]
  30.     #[ORM\JoinColumn(nullablefalse)]
  31.     private ?Website $website null;
  32.     public function __construct()
  33.     {
  34.         parent::__construct();
  35.         $this->customers = new ArrayCollection();
  36.     }
  37.     public function __toString()
  38.     {
  39.         return $this->getName();
  40.     }
  41.     public function getId(): ?string
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getSlug(): ?string
  46.     {
  47.         return $this->slug;
  48.     }
  49.     public function setSlug(string $slug): static
  50.     {
  51.         $this->slug $slug;
  52.         return $this;
  53.     }
  54.     public function getName(): ?string
  55.     {
  56.         return $this->name;
  57.     }
  58.     public function setName(string $name): static
  59.     {
  60.         $this->name $name;
  61.         return $this;
  62.     }
  63.     public function getCount(): ?int
  64.     {
  65.         return count($this->getUsers());
  66.     }
  67.     public function setCount(?int $count): static
  68.     {
  69.         $this->count $count;
  70.         return $this;
  71.     }
  72.     public function getViews(): ?int
  73.     {
  74.         return $this->views;
  75.     }
  76.     public function setViews(?int $views): static
  77.     {
  78.         $this->views $views;
  79.         return $this;
  80.     }
  81.     /**
  82.      * @return Collection<int, Customer>
  83.      */
  84.     public function getCustomers(): Collection
  85.     {
  86.         return $this->customers;
  87.     }
  88.     public function addCustomer(Customer $customer): static
  89.     {
  90.         if (!$this->customers->contains($customer)) {
  91.             $this->customers->add($customer);
  92.             $customer->setCampaign($this);
  93.         }
  94.         return $this;
  95.     }
  96.     public function removeCustomer(Customer $customer): static
  97.     {
  98.         if ($this->customers->removeElement($customer)) {
  99.             // set the owning side to null (unless already changed)
  100.             if ($customer->getCampaign() === $this) {
  101.                 $customer->setCampaign(null);
  102.             }
  103.         }
  104.         return $this;
  105.     }
  106.     public function getWebsite(): ?Website
  107.     {
  108.         return $this->website;
  109.     }
  110.     public function setWebsite(?Website $website): static
  111.     {
  112.         $this->website $website;
  113.         return $this;
  114.     }
  115. }