<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\MenuRepository")
*/
class Menu
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="bigint")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $title;
/**
* @ORM\Column(type="text")
*/
private $description;
/**
* @ORM\Column(type="integer")
*/
private $status;
/**
* @ORM\Column(type="string", length=128)
*/
private $position;
/**
* @ORM\Column(type="text")
*/
private $attributes;
/**
* @ORM\Column(type="datetime")
*/
private $modified_at;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\OneToMany(targetEntity="App\Entity\MenuItem", mappedBy="menu", orphanRemoval=true, cascade={"persist", "remove"}, fetch="EAGER")
*/
private $menuItems;
/**
* @ORM\Column(type="boolean")
*/
private $show_title;
public function __construct()
{
$this->title = "";
$this->description = "";
$this->status = 1;
$this->position = "";
$this->attributes = "";
$this->show_title = true;
$this->menuItems = new ArrayCollection();
$this->created_at = new \DateTime("now");
$this->modified_at = new \DateTime("now");
}
public function getId()
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title = null): self
{
$this->title = $title ? $title : "";
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description = null): self
{
$this->description = $description ? $description : "";
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getPosition(): ?string
{
return $this->position;
}
public function setPosition(string $position = null): self
{
$this->position = $position ? $position : "";
return $this;
}
public function getAttributes(): ?string
{
return $this->attributes;
}
public function setAttributes(string $attributes = null): self
{
$this->attributes = $attributes ? $attributes : "";
return $this;
}
public function __toString ()
{
return $this->title;
}
public function getModifiedAt(): ?\DateTimeInterface
{
return $this->modified_at;
}
public function setModifiedAt(\DateTimeInterface $modified_at): self
{
$this->modified_at = $modified_at;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
/**
* @return Collection|MenuItem[]
*/
public function getMenuItems(): Collection
{
return $this->menuItems;
}
public function addMenuItem(MenuItem $menuItem): self
{
if (!$this->menuItems->contains($menuItem)) {
$this->menuItems[] = $menuItem;
$menuItem->setMenu($this);
}
return $this;
}
public function removeMenuItem(MenuItem $menuItem): self
{
if ($this->menuItems->contains($menuItem)) {
$this->menuItems->removeElement($menuItem);
// set the owning side to null (unless already changed)
if ($menuItem->getMenu() === $this) {
$menuItem->setMenu(null);
}
}
return $this;
}
public function getShowTitle(): ?bool
{
return $this->show_title;
}
public function setShowTitle(bool $show_title): self
{
$this->show_title = $show_title;
return $this;
}
}