src/Entity/Menu.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\MenuRepository")
  8.  */
  9. class Menu
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="bigint")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\Column(type="string", length=255)
  19.      */
  20.     private $title;
  21.     /**
  22.      * @ORM\Column(type="text")
  23.      */
  24.     private $description;
  25.     /**
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private $status;
  29.     /**
  30.      * @ORM\Column(type="string", length=128)
  31.      */
  32.     private $position;
  33.     /**
  34.      * @ORM\Column(type="text")
  35.      */
  36.     private $attributes;
  37.     /**
  38.      * @ORM\Column(type="datetime")
  39.      */
  40.     private $modified_at;
  41.     /**
  42.      * @ORM\Column(type="datetime")
  43.      */
  44.     private $created_at;
  45.     /**
  46.      * @ORM\OneToMany(targetEntity="App\Entity\MenuItem", mappedBy="menu", orphanRemoval=true, cascade={"persist", "remove"}, fetch="EAGER")
  47.      */
  48.     private $menuItems;
  49.     /**
  50.      * @ORM\Column(type="boolean")
  51.      */
  52.     private $show_title;
  53.     public function __construct()
  54.     {
  55.         $this->title "";
  56.         $this->description "";
  57.         $this->status 1;
  58.         $this->position "";
  59.         $this->attributes "";
  60.         $this->show_title true;
  61.         
  62.         $this->menuItems = new ArrayCollection();
  63.         
  64.         $this->created_at = new \DateTime("now");
  65.         $this->modified_at = new \DateTime("now");
  66.         
  67.     }
  68.     public function getId()
  69.     {
  70.         return $this->id;
  71.     }
  72.     public function getTitle(): ?string
  73.     {
  74.         return $this->title;
  75.     }
  76.     public function setTitle(string $title null): self
  77.     {
  78.         $this->title $title $title "";
  79.         return $this;
  80.     }
  81.     public function getDescription(): ?string
  82.     {
  83.         return $this->description;
  84.     }
  85.     public function setDescription(string $description null): self
  86.     {
  87.         $this->description $description $description "";
  88.         return $this;
  89.     }
  90.     public function getStatus(): ?int
  91.     {
  92.         return $this->status;
  93.     }
  94.     public function setStatus(int $status): self
  95.     {
  96.         $this->status $status;
  97.         return $this;
  98.     }
  99.     public function getPosition(): ?string
  100.     {
  101.         return $this->position;
  102.     }
  103.     public function setPosition(string $position null): self
  104.     {
  105.         $this->position $position $position "";
  106.         return $this;
  107.     }
  108.     public function getAttributes(): ?string
  109.     {
  110.         return $this->attributes;
  111.     }
  112.     public function setAttributes(string $attributes null): self
  113.     {
  114.         $this->attributes $attributes $attributes "";
  115.         return $this;
  116.     }
  117.     
  118.     public function __toString ()
  119.     {
  120.         return $this->title;
  121.     }
  122.     public function getModifiedAt(): ?\DateTimeInterface
  123.     {
  124.         return $this->modified_at;
  125.     }
  126.     public function setModifiedAt(\DateTimeInterface $modified_at): self
  127.     {
  128.         $this->modified_at $modified_at;
  129.         return $this;
  130.     }
  131.     public function getCreatedAt(): ?\DateTimeInterface
  132.     {
  133.         return $this->created_at;
  134.     }
  135.     public function setCreatedAt(\DateTimeInterface $created_at): self
  136.     {
  137.         $this->created_at $created_at;
  138.         return $this;
  139.     }
  140.     
  141.     /**
  142.      * @return Collection|MenuItem[]
  143.      */
  144.     public function getMenuItems(): Collection
  145.     {
  146.         return $this->menuItems;
  147.     }
  148.     public function addMenuItem(MenuItem $menuItem): self
  149.     {
  150.         if (!$this->menuItems->contains($menuItem)) {
  151.             $this->menuItems[] = $menuItem;
  152.             $menuItem->setMenu($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeMenuItem(MenuItem $menuItem): self
  157.     {
  158.         if ($this->menuItems->contains($menuItem)) {
  159.             $this->menuItems->removeElement($menuItem);
  160.             // set the owning side to null (unless already changed)
  161.             if ($menuItem->getMenu() === $this) {
  162.                 $menuItem->setMenu(null);
  163.             }
  164.         }
  165.         
  166.         return $this;
  167.     }
  168.     public function getShowTitle(): ?bool
  169.     {
  170.         return $this->show_title;
  171.     }
  172.     public function setShowTitle(bool $show_title): self
  173.     {
  174.         $this->show_title $show_title;
  175.         return $this;
  176.     }
  177. }