<?php
namespace App\Entity;
use App\Repository\RolesRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: RolesRepository::class)]
class Roles
{
const USER_ROLE_BUYER = 'ROLE_BUYER';
const USER_ROLE_SELLER = 'ROLE_SELLER';
const USER_ROLE_ADMIN = 'ROLE_ADMIN';
const USER_ROLE_MODERATOR = 'ROLE_MODERATOR';
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 50)]
private ?string $name = null;
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'roles')]
private Collection $user;
public function __construct()
{
$this->user = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUser(): Collection
{
return $this->user;
}
public function addUser(User $user): static
{
if (!$this->user->contains($user)) {
$this->user->add($user);
}
return $this;
}
public function removeUser(User $user): static
{
$this->user->removeElement($user);
return $this;
}
}