<?php
namespace App\Entity;
use App\Repository\ProfileRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ProfileRepository::class)]
class Profile
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[Gedmo\Versioned]
#[ORM\Column(type: 'string', length: 64)]
#[Assert\NotBlank]
private ?string $name;
#[ORM\ManyToMany(targetEntity: MenuItemAdmin::class, inversedBy: 'profiles')]
private $menuitems;
public function __construct()
{
$this->menuitems = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, MenuItemAdmin>
*/
public function getMenuitems(): Collection
{
return $this->menuitems;
}
public function addMenuitem(MenuItemAdmin $menuitem): self
{
if (!$this->menuitems->contains($menuitem)) {
$this->menuitems[] = $menuitem;
}
return $this;
}
public function removeMenuitem(MenuItemAdmin $menuitem): self
{
$this->menuitems->removeElement($menuitem);
return $this;
}
public function __toString(): string
{
return $this->name;
}
}