Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Entity;
- use App\Repository\GroupRepository;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- #[ORM\Entity(repositoryClass: GroupRepository::class)]
- #[ORM\Table(name: '`group`')]
- class Group
- {
- #[ORM\Id]
- #[ORM\GeneratedValue]
- #[ORM\Column]
- private ?int $id = null;
- #[ORM\Column(length: 255)]
- private ?string $name = null;
- /**
- * @var Collection<int, User>
- */
- #[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'groups')]
- private Collection $users;
- public function __construct()
- {
- $this->users = 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 getUsers(): Collection
- {
- return $this->users;
- }
- public function addUser(User $user): static
- {
- if (!$this->users->contains($user)) {
- $this->users->add($user);
- }
- return $this;
- }
- public function removeUser(User $user): static
- {
- $this->users->removeElement($user);
- return $this;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement