src/Entity/Banner.php line 18

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Bornay\ZonaBundle\Entity\Zona;
  7. use Bornay\ZonaBundle\Entity\BannerItem;
  8. /**
  9.  * Banner
  10.  *
  11.  * @ORM\Entity
  12.  * @ORM\Table(name="banner")
  13.  * @ORM\Entity(repositoryClass="App\Repository\BannerRepository")  
  14.  */
  15. class Banner
  16. {
  17.     /**
  18.      * @var integer
  19.      * @ORM\Column(name="id", type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @var string
  26.      *
  27.      * @ORM\Column(name="nombre", type="string", length=64)
  28.      */
  29.     private $nombre;
  30.     
  31.     /**
  32.      * @var boolean
  33.      *
  34.      * @ORM\Column(name="activo", type="boolean", options={"default":0})
  35.      */
  36.     private $activo;
  37.     
  38.     /**
  39.      * @var Collection
  40.      * @ORM\OneToMany(targetEntity="BannerItem", mappedBy="banner" , cascade={"persist"}, orphanRemoval=true)
  41.      * @ORM\OrderBy({"position" = "ASC"})
  42.      */
  43.     protected $items;    
  44.     
  45.     /**
  46.      * @var string
  47.      *
  48.      * @ORM\Column(name="zona", type="string", length=64)
  49.      */
  50.     protected $zona;
  51.     
  52.     
  53.     public function __construct()
  54.     {
  55.         $this->items = new ArrayCollection();
  56.     }
  57.     
  58.     public function __toString()
  59.     {
  60.         return $this->nombre;
  61.     }
  62.     public function getId(): ?int
  63.     {
  64.         return $this->id;
  65.     }
  66.     public function getNombre(): ?string
  67.     {
  68.         return $this->nombre;
  69.     }
  70.     public function setNombre(string $nombre): self
  71.     {
  72.         $this->nombre $nombre;
  73.         return $this;
  74.     }
  75.     public function isActivo(): ?bool
  76.     {
  77.         return $this->activo;
  78.     }
  79.     public function setActivo(bool $activo): self
  80.     {
  81.         $this->activo $activo;
  82.         return $this;
  83.     }
  84.     public function getZona(): ?string
  85.     {
  86.         return $this->zona;
  87.     }
  88.     public function setZona(string $zona): self
  89.     {
  90.         $this->zona $zona;
  91.         return $this;
  92.     }
  93.     /**
  94.      * @return Collection<int, BannerItem>
  95.      */
  96.     public function getItems(): Collection
  97.     {
  98.         return $this->items;
  99.     }
  100.     public function addItem(BannerItem $item): self
  101.     {
  102.         if (!$this->items->contains($item)) {
  103.             $item->setBanner($this);
  104.             $this->items->add($item);
  105.             
  106.         }
  107.         return $this;
  108.     }
  109.     public function removeItem(BannerItem $item): self
  110.     {
  111.         if ($this->items->removeElement($item)) {
  112.             // set the owning side to null (unless already changed)
  113.             if ($item->getBanner() === $this) {
  114.                 $item->setBanner(null);
  115.             }
  116.         }
  117.         return $this;
  118.     }      
  119.     
  120.     
  121.     
  122. }