<?phpnamespace App\Entity;use App\Entity\Traits\CommonTrait;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Doctrine\ORM\Mapping as ORM;use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;/** * @ORM\Entity(repositoryClass="App\Repository\CampaignRepository") * @ORM\Table(name="ad_campaign") * @ORM\HasLifecycleCallbacks() * @UniqueEntity({"uuid"}) */class Campaign{ use CommonTrait; /** * @var string $code * @ORM\Column(name="code", type="string", nullable=true) */ private $code; /** * @var string $description * @ORM\Column(name="description", type="text", nullable=true) */ private $description; /** * @var \DateTime $createdAt * @ORM\Column(name="created_at", type="datetime", nullable=true) */ private $createdAt; /** * @var \DateTime $updatedAt * @ORM\Column(name="updated_at", type="datetime", nullable=true) */ private $updatedAt; /** * @ORM\OneToMany(targetEntity=Ad::class, mappedBy="campaign") */ private $ads; public function __construct() { $this->ads = new ArrayCollection(); } /** * * @return string */ public function __toString() { return $this->getCode(); } /** * Set code * * @param string $code * @return Campaign */ public function setCode($code) { $this->code = $code; return $this; } /** * Get code * * @return string */ public function getCode() { return $this->code; } /** * Set description * * @param string $description * @return Campaign */ public function setDescription($description) { $this->description = $description; return $this; } /** * Get description * * @return string */ public function getDescription() { return $this->description; } /** * Set createdAt * * @param \DateTime $createdAt * @return Campaign */ public function setCreatedAt($createdAt) { $this->createdAt = $createdAt; return $this; } /** * Get createdAt * * @return \DateTime */ public function getCreatedAt() { return $this->createdAt; } /** * Set updatedAt * * @param \DateTime $updatedAt * @return Campaign */ public function setUpdatedAt($updatedAt) { $this->updatedAt = $updatedAt; return $this; } /** * Get updatedAt * * @return \DateTime */ public function getUpdatedAt() { return $this->updatedAt; } public function getAdsCount() { return count($this->ads); } /** * @return Collection|Ad[] */ public function getAds(): Collection { return $this->ads; } public function addAd(Ad $ad): self { if (!$this->ads->contains($ad)) { $this->ads[] = $ad; $ad->setCampaign($this); } return $this; } public function removeAd(Ad $ad): self { if ($this->ads->removeElement($ad)) { // set the owning side to null (unless already changed) if ($ad->getCampaign() === $this) { $ad->setCampaign(null); } } return $this; }}