src/Entity/CategoriesUsers.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Trait\CreatedAtTrait;
  4. use App\Repository\CategoriesUsersRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. #[ORM\Entity(repositoryClassCategoriesUsersRepository::class)]
  10. class CategoriesUsers
  11. {   
  12.     use CreatedAtTrait;
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column(length255)]
  18.     private ?string $name null;
  19.     #[ORM\Column(typeTypes::TEXT)]
  20.     private ?string $description null;
  21.     #[ORM\Column(length255)]
  22.     private ?string $slug null;
  23.     #[ORM\OneToMany(mappedBy'categoriesusers'targetEntityUsers::class)]
  24.     private Collection $users;
  25.     public function __construct()
  26.     {
  27.         /// $this->entreprises = new ArrayCollection();
  28.         $this->created_at = new \DateTimeImmutable();
  29.         $this->users = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int
  32.     {
  33.         return $this->id;
  34.     }
  35.     public function getName(): ?string
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function setName(string $name): static
  40.     {
  41.         $this->name $name;
  42.         return $this;
  43.     }
  44.     public function getDescription(): ?string
  45.     {
  46.         return $this->description;
  47.     }
  48.     public function setDescription(string $description): static
  49.     {
  50.         $this->description $description;
  51.         return $this;
  52.     }
  53.     public function getSlug(): ?string
  54.     {
  55.         return $this->slug;
  56.     }
  57.     public function setSlug(string $slug): static
  58.     {
  59.         $this->slug $slug;
  60.         return $this;
  61.     }
  62.     /**
  63.      * @return Collection<int, Users>
  64.      */
  65.     public function getUsers(): Collection
  66.     {
  67.         return $this->users;
  68.     }
  69.     public function addUser(Users $user): static
  70.     {
  71.         if (!$this->users->contains($user)) {
  72.             $this->users->add($user);
  73.             $user->setCategoriesusers($this);
  74.         }
  75.         return $this;
  76.     }
  77.     public function removeUser(Users $user): static
  78.     {
  79.         if ($this->users->removeElement($user)) {
  80.             // set the owning side to null (unless already changed)
  81.             if ($user->getCategoriesusers() === $this) {
  82.                 $user->setCategoriesusers(null);
  83.             }
  84.         }
  85.         return $this;
  86.     }
  87. }