src/Entity/Menu.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\ActiveTrait;
  4. use App\Entity\Traits\DeleteTrait;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * News.
  11.  *
  12.  * @Gedmo\Loggable
  13.  */
  14. #[ORM\Entity(repositoryClass\App\Repository\MenuRepository::class)]
  15. #[ORM\Table(name'menus')]
  16. class Menu implements \Stringable
  17. {
  18.     use ActiveTrait;
  19.     use DeleteTrait;
  20.     use TimestampableEntity;
  21.     public $menu_json;
  22.     #[ORM\Column(name'id'type'integer')]
  23.     #[ORM\Id]
  24.     #[ORM\GeneratedValue(strategy'AUTO')]
  25.     private int $id;
  26.     #[Assert\NotBlank(message'The Identifier should not be blank')]
  27.     #[ORM\Column(name'identifier'type'string'length255)]
  28.     private ?string $identifier null;
  29.     #[ORM\ManyToOne(targetEntity\App\Entity\User::class, inversedBy'menuupdated')]
  30.     #[ORM\JoinColumn(name'update_by'referencedColumnName'id')]
  31.     private ?\App\Entity\User $updatedBy null;
  32.     #[ORM\OneToMany(targetEntity\App\Entity\MenuItems::class, mappedBy'menuId')]
  33.     private \Doctrine\Common\Collections\Collection $menu_items;
  34.     /**
  35.      * Constructor.
  36.      */
  37.     public function __construct()
  38.     {
  39.         $this->menu_items = new \Doctrine\Common\Collections\ArrayCollection();
  40.     }
  41.     public function __toString(): string
  42.     {
  43.         return $this->getIdentifier();
  44.     }
  45.     /**
  46.      * Get id.
  47.      *
  48.      * @return int
  49.      */
  50.     public function getId()
  51.     {
  52.         return $this->id;
  53.     }
  54.     /**
  55.      * Set identifier.
  56.      *
  57.      * @param string $identifier
  58.      *
  59.      * @return Menu
  60.      */
  61.     public function setIdentifier($identifier)
  62.     {
  63.         $this->identifier $identifier;
  64.         return $this;
  65.     }
  66.     /**
  67.      * Get identifier.
  68.      *
  69.      * @return string
  70.      */
  71.     public function getIdentifier()
  72.     {
  73.         return $this->identifier;
  74.     }
  75.     /**
  76.      * Set menu_items.
  77.      *
  78.      * @param array $menuItems
  79.      *
  80.      * @return Menu
  81.      */
  82.     public function setMenuItems($menuItems)
  83.     {
  84.         $this->menu_items $menuItems;
  85.         return $this;
  86.     }
  87.     /**
  88.      * Get menu_items.
  89.      *
  90.      * @return array
  91.      */
  92.     public function getMenuItems()
  93.     {
  94.         return $this->menu_items;
  95.     }
  96.     /**
  97.      * Set updatedBy.
  98.      *
  99.      * @return Menu
  100.      */
  101.     public function setUpdatedBy(User $updatedBy null)
  102.     {
  103.         $this->updatedBy $updatedBy;
  104.         return $this;
  105.     }
  106.     /**
  107.      * Get updatedBy.
  108.      *
  109.      * @return \App\Entity\User
  110.      */
  111.     public function getUpdatedBy()
  112.     {
  113.         return $this->updatedBy;
  114.     }
  115.     /**
  116.      * Add menu_items.
  117.      *
  118.      * @return Menu
  119.      */
  120.     public function addMenuItem(MenuItems $menuItems)
  121.     {
  122.         $this->menu_items[] = $menuItems;
  123.         return $this;
  124.     }
  125.     /**
  126.      * Remove menu_items.
  127.      */
  128.     public function removeMenuItem(MenuItems $menuItems)
  129.     {
  130.         $this->menu_items->removeElement($menuItems);
  131.     }
  132. }