HEX
Server: Apache
System: Linux WWW 6.1.0-40-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.153-1 (2025-09-20) x86_64
User: web11 (1011)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/dvpis2025/dvpis.kaunokolegija.lt/src/Entity/FieldOfStudyGroup.php
<?php

namespace App\Entity;

use App\Repository\FieldOfStudyGroupRepository;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * FieldOfStudyGroup
 */
#[ORM\Table(name: 'field_of_study_group')]
#[ORM\Entity(repositoryClass: FieldOfStudyGroupRepository::class)]
class FieldOfStudyGroup
{
    #[ORM\Column]
    #[ORM\Id]
    #[ORM\GeneratedValue]
    private ?int $id = null;

    /**
     * @var string
     */
    #[ORM\Column(name: 'short_name', type: 'string', length: 255, unique: true)]
    private $shortName;

    /**
     * @var string
     */
    #[ORM\Column(name: 'name', type: 'string', length: 255)]
    private $name;

    #[ORM\OneToMany(mappedBy: 'fieldOfStudyGroup', targetEntity: FieldOfStudy::class)]
    private Collection $fieldOfStudies;

    public function __construct()
    {
        $this->fieldOfStudies = new ArrayCollection();
    }

    /**
     * @return Collection<int, FieldOfStudy>
     */
    public function getFieldOfStudies(): Collection
    {
        return $this->fieldOfStudies;
    }

    public function setFieldOfStudies($fieldOfStudies)
    {
        $this->fieldOfStudies = $fieldOfStudies;
        return $this;
    }

    public function __toString()
    {
        return $this->name;
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function setName(string $name): static
    {
        $this->name = $name;

        return $this;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function getShortName(): ?string
    {
        return $this->shortName;
    }

    public function setShortName(string $shortName): static
    {
        $this->shortName = $shortName;

        return $this;
    }

    public function addFieldOfStudy(FieldOfStudy $fieldOfStudy): static
    {
        if (!$this->fieldOfStudies->contains($fieldOfStudy)) {
            $this->fieldOfStudies->add($fieldOfStudy);
            $fieldOfStudy->setFieldOfStudyGroup($this);
        }

        return $this;
    }

    public function removeFieldOfStudy(FieldOfStudy $fieldOfStudy): static
    {
        if ($this->fieldOfStudies->removeElement($fieldOfStudy)) {
            // set the owning side to null (unless already changed)
            if ($fieldOfStudy->getFieldOfStudyGroup() === $this) {
                $fieldOfStudy->setFieldOfStudyGroup(null);
            }
        }

        return $this;
    }
}