| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?php
- declare(strict_types=1);
- namespace App\Entity\Education;
- use ApiPlatform\Metadata\ApiResource;
- use App\Entity\Billing\ResidenceArea;
- use App\Entity\Core\Tagg;
- use App\Repository\Education\EducationNotationRepository;
- // use DH\Auditor\Provider\Doctrine\Auditing\Annotation\Auditable;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * Classe ... qui ...
- */
- #[ApiResource(operations: [])]
- // #[Auditable]
- #[ORM\Entity(repositoryClass: EducationNotationRepository::class)]
- class EducationNotation
- {
- #[ORM\Id]
- #[ORM\Column]
- #[ORM\GeneratedValue]
- private ?int $id = null;
- #[ORM\ManyToOne(inversedBy: 'educationNotations')]
- #[ORM\JoinColumn(nullable: false)]
- private EducationStudent $educationStudent;
- #[ORM\ManyToOne(inversedBy: 'educationNotations')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- private ?CriteriaNotation $criteriaNotation;
- #[ORM\ManyToOne(inversedBy: 'educationNotations')]
- #[ORM\JoinColumn(referencedColumnName: 'id', nullable: true, onDelete: 'SET NULL')]
- private ?EducationNotationCriteriaConfig $criteriaNotationConfig;
- /** @var Collection<int, Tagg> */
- #[ORM\ManyToMany(targetEntity: Tagg::class, inversedBy: 'educationNotations', cascade: ['persist'])]
- #[ORM\JoinTable(name: 'tag_educationNotation')]
- #[ORM\JoinColumn(name: 'educationNotation_id', referencedColumnName: 'id')]
- #[ORM\InverseJoinColumn(name: 'tag_id', referencedColumnName: 'id')]
- private Collection $tags;
- // @see https://github.com/symfony/symfony/discussions/43599#discussioncomment-1514811
- #[ORM\Column(type: 'decimal', precision: 10, scale: 2, nullable: true)]
- #[Assert\Range(notInRangeMessage: 'between_{{ min }}_and_{{ max }}', min: 0, max: 100)]
- private ?string $note = null;
- public function __construct()
- {
- $this->tags = new ArrayCollection();
- }
- public function getId(): ?int
- {
- return $this->id;
- }
- public function getEducationStudent(): ?EducationStudent
- {
- return $this->educationStudent;
- }
- public function setEducationStudent(?EducationStudent $educationStudent): self
- {
- $this->educationStudent = $educationStudent;
- return $this;
- }
- public function getCriteriaNotation(): ?CriteriaNotation
- {
- return $this->criteriaNotation;
- }
- public function setCriteriaNotation(?CriteriaNotation $criteriaNotation): self
- {
- $this->criteriaNotation = $criteriaNotation;
- return $this;
- }
- public function getCriteriaNotationConfig(): ?EducationNotationCriteriaConfig
- {
- return $this->criteriaNotationConfig;
- }
- public function setCriteriaNotationConfig(?EducationNotationCriteriaConfig $criteriaNotationConfig): self
- {
- $this->criteriaNotationConfig = $criteriaNotationConfig;
- return $this;
- }
- /**
- * @return Collection<int, Tagg>
- */
- public function getTags(): Collection
- {
- return $this->tags;
- }
- public function addTag(Tagg $tag): self
- {
- if (!$this->tags->contains($tag)) {
- $this->tags[] = $tag;
- }
- return $this;
- }
- public function removeTag(Tagg $tag): self
- {
- $this->tags->removeElement($tag);
- return $this;
- }
- public function setNote(?float $note): self
- {
- $this->note = (string)$note;
- return $this;
- }
- public function getNote(): ?float
- {
- // TODO: pour moi le round il est pas à sa place ici? vaudrait pas mieux le mettre dans le setter?
- return !is_null($this->note) ? round((float)$this->note, 2) : null;
- }
- }
|