src/Entity/CompanyMember.php line 13

  1. <?php
  2. namespace App\Entity;
  3. use DateTimeImmutable;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\Common\Collections\Collection;
  7. use App\Repository\CompanyMemberRepository;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. #[ORM\Entity(repositoryClassCompanyMemberRepository::class)]
  10. class CompanyMember
  11. {
  12.     #[ORM\Id]
  13.     #[ORM\GeneratedValue]
  14.     #[ORM\Column]
  15.     private ?int $id null;
  16.     #[ORM\Column(nullabletrue)]
  17.     private ?\DateTimeImmutable $lastEvaluation null;
  18.     #[ORM\Column(length50)]
  19.     private ?string $firstname null;
  20.     #[ORM\Column(length50)]
  21.     private ?string $lastname null;
  22.     #[ORM\OneToMany(mappedBy'companyMember'targetEntityEvaluation::class)]
  23.     private Collection $evaluations;
  24.     #[ORM\ManyToOne(inversedBy'companyMembers')]
  25.     #[ORM\JoinColumn(nullablefalse)]
  26.     private ?Company $company null;
  27.     #[ORM\OneToOne(mappedBy'companyMember'cascade: ['persist''remove'])]
  28.     private ?User $user null;
  29.     #[ORM\Column]
  30.     private ?bool $active null;
  31.     public function __construct()
  32.     {
  33.         $this->evaluations = new ArrayCollection();
  34.         $this->active true;
  35.     }
  36.     public function getName()
  37.     {
  38.         $name $this->getFirstname() . ' ' $this->getLastname();
  39.         return $name;
  40.     }
  41.     public function getId(): ?int
  42.     {
  43.         return $this->id;
  44.     }
  45.     public function getLastEvaluation(): ?\DateTimeImmutable
  46.     {
  47.         return $this->lastEvaluation;
  48.     }
  49.     public function setLastEvaluation(?\DateTimeImmutable $lastEvaluation): self
  50.     {
  51.         $this->lastEvaluation $lastEvaluation;
  52.         return $this;
  53.     }
  54.     public function getFirstname(): ?string
  55.     {
  56.         return $this->firstname;
  57.     }
  58.     public function setFirstname(string $firstname): self
  59.     {
  60.         $this->firstname $firstname;
  61.         return $this;
  62.     }
  63.     public function getLastname(): ?string
  64.     {
  65.         return $this->lastname;
  66.     }
  67.     public function setLastname(string $lastname): self
  68.     {
  69.         $this->lastname $lastname;
  70.         return $this;
  71.     }
  72.     /**
  73.      * @return Collection<int, Evaluation>
  74.      */
  75.     public function getEvaluations(): Collection
  76.     {
  77.         return $this->evaluations;
  78.     }
  79.     public function getCompany(): ?Company
  80.     {
  81.         return $this->company;
  82.     }
  83.     public function setCompany(?Company $company): self
  84.     {
  85.         $this->company $company;
  86.         return $this;
  87.     }
  88.     public function getUser(): ?User
  89.     {
  90.         return $this->user;
  91.     }
  92.     public function setUser(?User $user): self
  93.     {
  94.         // unset the owning side of the relation if necessary
  95.         if ($user === null && $this->user !== null) {
  96.             $this->user->setCompanyMember(null);
  97.         }
  98.         // set the owning side of the relation if necessary
  99.         if ($user !== null && $user->getCompanyMember() !== $this) {
  100.             $user->setCompanyMember($this);
  101.         }
  102.         $this->user $user;
  103.         return $this;
  104.     }
  105.     public function isActive(): ?bool
  106.     {
  107.         return $this->active;
  108.     }
  109.     public function setActive(bool $active): self
  110.     {
  111.         $this->active $active;
  112.         return $this;
  113.     }
  114. }