/
forest-lynx
/
project
Обзор
Документация
Войти
/
forest-lynx
/
project
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Entity/Position.php
93 строки
2 KB
forest-lynx
init
04 дек 2024, 10:44
04 дек 2024, 10:44
f4ceba2
Код
Авторство
О чём код?
<?php namespace App\Entity; use App\Repository\PositionRepository; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\Collection; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity(repositoryClass: PositionRepository::class)] class Position { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $name = null; #[ORM\Column(type: Types::TEXT, nullable: true)] private ?string $description = null; /** * @var Collection<int, Employment> */ #[ORM\OneToMany(targetEntity: Employment::class, mappedBy: 'position', fetch: 'EAGER')] private Collection $employments; public function __construct() { $this->employments = new ArrayCollection(); } public function getId(): ?int { return $this->id; } public function getName(): ?string { return $this->name; } public function setName(string $name): static { $this->name = $name; return $this; } public function getDescription(): ?string { return $this->description; } public function setDescription(?string $description): static { $this->description = $description; 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->setPosition($this); } return $this; } public function removeEmployment(Employment $employment): static { if ($this->employments->removeElement($employment)) { if ($employment->getPosition() === $this) { $employment->setPosition(null); } } return $this; } }