src/Entity/Degree.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\DegreeRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use JMS\Serializer\Annotation\ExclusionPolicy;
  8. use JMS\Serializer\Annotation\Expose;
  9. #[ORM\Table(name'degree')]
  10. #[ORM\Entity(repositoryClassDegreeRepository::class)]
  11. #[ORM\UniqueConstraint(name'degree_name_unique'columns: ['name'])]
  12. class Degree {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column(type'integer')]
  16.     private ?int $id null;
  17.     #[ORM\Column(name'name'type'string'length255)]
  18.     private string $name;
  19.     #[ORM\Column(name'description'type'text'nullabletrue)]
  20.     private ?string $description;
  21.     #[ORM\Column(name'level'type'integer')]
  22.     private int $level;
  23.     #[ORM\ManyToMany(targetEntitySchool::class, mappedBy'degree')]
  24.     private Collection $schools;
  25.     #[ORM\ManyToOne(targetEntityActivity::class)]
  26.     #[ORM\JoinColumn(nullabletrue)]
  27.     private ?Activity $activity null;
  28.     public function __construct() {
  29.         $this->schools = new ArrayCollection();
  30.     }
  31.     public function getId(): ?int {
  32.         return $this->id;
  33.     }
  34.     public function setName(string $name): self {
  35.         $this->name $name;
  36.         return $this;
  37.     }
  38.     public function getName(): string {
  39.         return $this->name;
  40.     }
  41.     public function getDescription(): ?string {
  42.         return $this->description;
  43.     }
  44.     public function setDescription(?string $description): self {
  45.         $this->description $description;
  46.         return $this;
  47.     }
  48.     public function getLevel(): int {
  49.         return $this->level;
  50.     }
  51.     public function setLevel($level): self {
  52.         $this->level $level;
  53.         return $this;
  54.     }
  55.     public function getActivity(): ?Activity {
  56.         return $this->activity;
  57.     }
  58.     public function setActivity(?Activity $activity): self {
  59.         $this->activity $activity;
  60.         return $this;
  61.     }
  62.     public function __toString() {
  63.         return $this->name;
  64.     }
  65.     public function addSchool(School $school): self {
  66.         $this->schools->add($school);
  67.         return $this;
  68.     }
  69.     public function removeSchool(School $school): void {
  70.         $this->schools->removeElement($school);
  71.     }
  72.     public function getSchools(): Collection {
  73.         return $this->schools;
  74.     }
  75. }