Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\Entity(repositoryClass="App\Repository\RoleRepository")
  8. */
  9. class Role
  10. {
  11. /**
  12. * @ORM\Id()
  13. * @ORM\GeneratedValue()
  14. * @ORM\Column(type="integer")
  15. */
  16. private $id;
  17. /**
  18. * @ORM\Column(type="string", length=255)
  19. */
  20. private $title;
  21. /**
  22. * @ORM\ManyToMany(targetEntity="App\Entity\User", inversedBy="userRoles")
  23. */
  24. private $users;
  25. public function __construct()
  26. {
  27. $this->users = new ArrayCollection();
  28. }
  29. public function getId(): ?int
  30. {
  31. return $this->id;
  32. }
  33. public function getTitle(): ?string
  34. {
  35. return $this->title;
  36. }
  37. public function setTitle(string $title): self
  38. {
  39. $this->title = $title;
  40. return $this;
  41. }
  42. /**
  43. * @return Collection|User[]
  44. */
  45. public function getUsers(): Collection
  46. {
  47. return $this->users;
  48. }
  49. public function addUser(User $user): self
  50. {
  51. if (!$this->users->contains($user)) {
  52. $this->users[] = $user;
  53. }
  54. return $this;
  55. }
  56. public function removeUser(User $user): self
  57. {
  58. if ($this->users->contains($user)) {
  59. $this->users->removeElement($user);
  60. }
  61. return $this;
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement