File: /var/www/dvpis2026/dvpis.kaunokolegija.lt/src/Entity/Position.php
<?php
namespace App\Entity;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* Position
*/
#[ORM\Table(name: 'position')]
#[ORM\Entity(repositoryClass: \App\Repository\PositionRepository::class)]
class Position
{
#[ORM\Column]
#[ORM\Id]
#[ORM\GeneratedValue]
private ?int $id = null;
/**
* @var string
*/
#[ORM\Column(name: 'position_name', type: 'string', length: 255, unique: true)]
private $positionName;
/**
* @var string
*/
#[ORM\Column(name: 'role', type: 'string', length: 255, nullable: false)]
private $role;
#[ORM\OneToMany(mappedBy: 'position', targetEntity: User::class)]
private Collection $users;
public function __construct()
{
$this->users = new ArrayCollection();
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function setUsers($users)
{
$this->users = $users;
return $this;
}
public function __toString()
{
return $this->positionName;
}
public function getRole(): ?string
{
return $this->role;
}
public function setRole(string $role): static
{
$this->role = $role;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function setPositionName(string $positionName): static
{
$this->positionName = $positionName;
return $this;
}
public function getPositionName(): ?string
{
return $this->positionName;
}
public function addUser(User $user): static
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->setPosition($this);
}
return $this;
}
public function removeUser(User $user): static
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getPosition() === $this) {
$user->setPosition(null);
}
}
return $this;
}
}