src/Entity/Campaign.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\CommonTrait;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\CampaignRepository")
  10.  * @ORM\Table(name="ad_campaign")
  11.  * @ORM\HasLifecycleCallbacks()
  12.  * @UniqueEntity({"uuid"})
  13.  */
  14. class Campaign
  15. {
  16.     use CommonTrait;
  17.     /**
  18.      * @var string $code
  19.      * @ORM\Column(name="code", type="string", nullable=true)
  20.      */
  21.     private $code;
  22.     /**
  23.      * @var string $description
  24.      * @ORM\Column(name="description", type="text", nullable=true)
  25.      */
  26.     private $description;
  27.     /**
  28.      * @var \DateTime $createdAt
  29.      * @ORM\Column(name="created_at", type="datetime", nullable=true)
  30.      */
  31.     private $createdAt;
  32.     /**
  33.      * @var \DateTime $updatedAt
  34.      * @ORM\Column(name="updated_at", type="datetime", nullable=true)
  35.      */
  36.     private $updatedAt;
  37.     /**
  38.      * @ORM\OneToMany(targetEntity=Ad::class, mappedBy="campaign")
  39.      */
  40.     private $ads;
  41.     public function __construct()
  42.     {
  43.         $this->ads = new ArrayCollection();
  44.     }
  45.     
  46.     /**
  47.      *
  48.      * @return string
  49.      */
  50.     public function __toString()
  51.     {
  52.         return $this->getCode();
  53.     }
  54.     
  55.     /**
  56.      * Set code
  57.      *
  58.      * @param string $code
  59.      * @return Campaign
  60.      */
  61.     public function setCode($code)
  62.     {
  63.         $this->code $code;
  64.         return $this;
  65.     }
  66.     /**
  67.      * Get code
  68.      *
  69.      * @return string 
  70.      */
  71.     public function getCode()
  72.     {
  73.         return $this->code;
  74.     }
  75.     /**
  76.      * Set description
  77.      *
  78.      * @param string $description
  79.      * @return Campaign
  80.      */
  81.     public function setDescription($description)
  82.     {
  83.         $this->description $description;
  84.         return $this;
  85.     }
  86.     /**
  87.      * Get description
  88.      *
  89.      * @return string 
  90.      */
  91.     public function getDescription()
  92.     {
  93.         return $this->description;
  94.     }
  95.     /**
  96.      * Set createdAt
  97.      *
  98.      * @param \DateTime $createdAt
  99.      * @return Campaign
  100.      */
  101.     public function setCreatedAt($createdAt)
  102.     {
  103.         $this->createdAt $createdAt;
  104.         return $this;
  105.     }
  106.     /**
  107.      * Get createdAt
  108.      *
  109.      * @return \DateTime
  110.      */
  111.     public function getCreatedAt()
  112.     {
  113.         return $this->createdAt;
  114.     }
  115.     /**
  116.      * Set updatedAt
  117.      *
  118.      * @param \DateTime $updatedAt
  119.      * @return Campaign
  120.      */
  121.     public function setUpdatedAt($updatedAt)
  122.     {
  123.         $this->updatedAt $updatedAt;
  124.         return $this;
  125.     }
  126.     /**
  127.      * Get updatedAt
  128.      *
  129.      * @return \DateTime
  130.      */
  131.     public function getUpdatedAt()
  132.     {
  133.         return $this->updatedAt;
  134.     }
  135.     public function getAdsCount()
  136.     {
  137.         return count($this->ads);
  138.     }
  139.     /**
  140.      * @return Collection|Ad[]
  141.      */
  142.     public function getAds(): Collection
  143.     {
  144.         return $this->ads;
  145.     }
  146.     public function addAd(Ad $ad): self
  147.     {
  148.         if (!$this->ads->contains($ad)) {
  149.             $this->ads[] = $ad;
  150.             $ad->setCampaign($this);
  151.         }
  152.         return $this;
  153.     }
  154.     public function removeAd(Ad $ad): self
  155.     {
  156.         if ($this->ads->removeElement($ad)) {
  157.             // set the owning side to null (unless already changed)
  158.             if ($ad->getCampaign() === $this) {
  159.                 $ad->setCampaign(null);
  160.             }
  161.         }
  162.         return $this;
  163.     }
  164. }