/
forest-lynx
/
project
Обзор
Документация
Войти
/
forest-lynx
/
project
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Entity/Developer.php
228 строк
5 KB
forest-lynx
init
04 дек 2024, 10:44
04 дек 2024, 10:44
f4ceba2
Код
Авторство
О чём код?
<?php namespace App\Entity; use App\Enum\EmployeeStatus; use App\Enum\Gender; use App\Repository\DeveloperRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: DeveloperRepository::class)] class Developer { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 120)] private ?string $lastName = null; #[ORM\Column(length: 120)] private ?string $firstName = null; #[ORM\Column(length: 120)] private ?string $middleName = null; #[ORM\Column(enumType: Gender::class)] private ?Gender $gender = null; #[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)] private ?\DateTimeInterface $birthday = null; #[ORM\Column(length: 120)] private ?string $email = null; #[ORM\Column(length: 20, nullable: true)] private ?string $phone = null; /** * @var Collection<int, Employment> */ #[ORM\OneToMany(targetEntity: Employment::class, mappedBy: 'developer', fetch: 'EAGER')] private Collection $employments; /** * @var Collection<int, ParticipationProject> */ #[ORM\OneToMany(targetEntity: ParticipationProject::class, mappedBy: 'developer', fetch: 'EAGER')] private Collection $projects; #[ORM\Column(enumType: EmployeeStatus::class)] private ?EmployeeStatus $status = null; public function __construct() { $this->employments = new ArrayCollection(); $this->projects = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getLastName(): ?string { return $this->lastName; } public function setLastName(string $lastName): static { $this->lastName = $lastName; return $this; } public function getFirstName(): ?string { return $this->firstName; } public function setFirstName(string $firstName): static { $this->firstName = $firstName; return $this; } public function getMiddleName(): ?string { return $this->middleName; } public function setMiddleName(string $middleName): static { $this->middleName = $middleName; return $this; } public function getGender(): ?Gender { return $this->gender; } public function setGender(Gender $gender): static { $this->gender = $gender; return $this; } public function getBirthday(): ?\DateTimeInterface { return $this->birthday; } public function setBirthday(?\DateTimeInterface $birthday): static { $this->birthday = $birthday; return $this; } public function getEmail(): ?string { return $this->email; } public function setEmail(string $email): static { $this->email = $email; return $this; } public function getPhone(): ?string { return $this->phone; } public function setPhone(?string $phone): static { $this->phone = $phone; return $this; } /** * @return Collection<int, Employment> */ public function getEmployments(): Collection { return $this->employments; } public function addEmployment(Employment $employment): static { if (!$this->employments->contains($employment)) { $this->employments->add($employment); $employment->setDeveloper($this); } return $this; } public function removeEmployment(Employment $employment): static { if ($this->employments->removeElement($employment)) { // set the owning side to null (unless already changed) if ($employment->getDeveloper() === $this) { $employment->setDeveloper(null); } } return $this; } /** * @return Collection<int, ParticipationProject> */ public function getProjects(): Collection { return $this->projects; } public function addProject(ParticipationProject $project): static { if (!$this->projects->contains($project)) { $this->projects->add($project); $project->setDeveloper($this); } return $this; } public function removeProject(ParticipationProject $project): static { if ($this->projects->removeElement($project)) { // set the owning side to null (unless already changed) if ($project->getDeveloper() === $this) { $project->setDeveloper(null); } } return $this; } public function getStatus(): ?EmployeeStatus { return $this->status; } public function setStatus(EmployeeStatus $status): static { $this->status = $status; return $this; } public function getFullName(): string { return sprintf('%s %s %s', $this->lastName, $this->firstName, $this->middleName); } }