src/Entity/Poste.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PosteRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Mapping\Annotation as Gedmo;
  8. #[ORM\Entity(repositoryClass: PosteRepository::class)]
  9. class Poste
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column(type: 'integer')]
  14.     private $id;
  15.     #[ORM\Column(type: 'string', length: 255, nullable: true)]
  16.     private $code;
  17.     #[ORM\Column(type: 'string', length: 255)]
  18.     private $nom;
  19.     #[ORM\OneToMany(mappedBy: 'poste', targetEntity: User::class)]
  20.     private $users;
  21.     #[Gedmo\Timestampable(on: 'create')]
  22.     #[ORM\Column(type: 'datetime')]
  23.     private $created_at;
  24.     #[Gedmo\Timestampable(on: 'update')]
  25.     #[ORM\Column(type: 'datetime')]
  26.     private $updated_at;
  27.     #[ORM\Column(type: 'integer')]
  28.     private $created_by;
  29.     #[ORM\Column(type: 'integer')]
  30.     private $updated_by;
  31.     #[ORM\Column(length: 255)]
  32.     private ?string $role = 'ROLE_USER';
  33.     #[ORM\ManyToMany(targetEntity: Document::class, mappedBy: 'visibilite')]
  34.     private Collection $documents;
  35.     public function __construct()
  36.     {
  37.         $this->users = new ArrayCollection();
  38.         $this->documents = new ArrayCollection();
  39.     }
  40.     public function getId(): ?int
  41.     {
  42.         return $this->id;
  43.     }
  44.     public function getCode(): ?string
  45.     {
  46.         return $this->code;
  47.     }
  48.     public function setCode(?string $code): self
  49.     {
  50.         $this->code = $code;
  51.         return $this;
  52.     }
  53.     public function getNom(): ?string
  54.     {
  55.         return $this->nom;
  56.     }
  57.     public function setNom(string $nom): self
  58.     {
  59.         $this->nom = $nom;
  60.         return $this;
  61.     }
  62.     /**
  63.      * @return Collection<int, User>
  64.      */
  65.     public function getUsers(): Collection
  66.     {
  67.         return $this->users;
  68.     }
  69.     public function addUser(User $user): self
  70.     {
  71.         if (!$this->users->contains($user)) {
  72.             $this->users[] = $user;
  73.             $user->setPoste($this);
  74.         }
  75.         return $this;
  76.     }
  77.     public function removeUser(User $user): self
  78.     {
  79.         if ($this->users->removeElement($user)) {
  80.             // set the owning side to null (unless already changed)
  81.             if ($user->getPoste() === $this) {
  82.                 $user->setPoste(null);
  83.             }
  84.         }
  85.         return $this;
  86.     }
  87.     public function getCreatedAt(): ?\DateTimeInterface
  88.     {
  89.         return $this->created_at;
  90.     }
  91.     public function setCreatedAt(\DateTimeInterface $created_at): self
  92.     {
  93.         $this->created_at = $created_at;
  94.         return $this;
  95.     }
  96.     public function getUpdatedAt(): ?\DateTimeInterface
  97.     {
  98.         return $this->updated_at;
  99.     }
  100.     public function setUpdatedAt(\DateTimeInterface $updated_at): self
  101.     {
  102.         $this->updated_at = $updated_at;
  103.         return $this;
  104.     }
  105.     public function getCreatedBy(): ?int
  106.     {
  107.         return $this->created_by;
  108.     }
  109.     public function setCreatedBy(int $created_by): self
  110.     {
  111.         $this->created_by = $created_by;
  112.         return $this;
  113.     }
  114.     public function getUpdatedBy(): ?int
  115.     {
  116.         return $this->updated_by;
  117.     }
  118.     public function setUpdatedBy(int $updated_by): self
  119.     {
  120.         $this->updated_by = $updated_by;
  121.         return $this;
  122.     }
  123.     public function getRole(): ?string
  124.     {
  125.         return $this->role;
  126.     }
  127.     public function setRole(string $role): self
  128.     {
  129.         $this->role = $role;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Collection<int, Document>
  134.      */
  135.     public function getDocuments(): Collection
  136.     {
  137.         return $this->documents;
  138.     }
  139.     public function addDocument(Document $document): self
  140.     {
  141.         if (!$this->documents->contains($document)) {
  142.             $this->documents->add($document);
  143.             $document->addVisibilite($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeDocument(Document $document): self
  148.     {
  149.         if ($this->documents->removeElement($document)) {
  150.             $document->removeVisibilite($this);
  151.         }
  152.         return $this;
  153.     }
  154. }