<?phpnamespace App\Entity;use App\Entity\Traits\Timestampable;use App\Repository\DailyAbsenceRepository;use Doctrine\DBAL\Types\Types;use Doctrine\ORM\Mapping as ORM;// Absence journalière — écoles primaires/maternelles uniquement. L'appel s'y// fait une fois par jour pour toute la classe (pas par matière/période comme// au secondaire, voir Absence.php qui reste lié à AgendaElement/Exams et// n'est pas touché). startAt/endAt sont des DATETIME (pas juste une heure ou// une date) pour permettre un intervalle explicite sur plusieurs jours (ex:// absent de mardi 14h à jeudi 10h), en plus du cas simple d'appel : "heure de// l'absence" connue immédiatement (startAt), "heure de retour" (endAt)// inconnue au moment de la saisie et complétée plus tard quand l'élève// revient — endAt est donc nullable, contrairement à une déclaration// d'intervalle où les deux bornes sont toujours connues d'avance. Entité// neuve et isolée : aucun rapport avec Absence/AgendaElement/Exams existants.#[ORM\HasLifecycleCallbacks]#[ORM\Entity(repositoryClass: DailyAbsenceRepository::class)]class DailyAbsence{ use Timestampable; #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?Student $student = null; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?TheClass $classe = null; // Primaire/maternelle : absence rattachée à l'évaluation mensuelle (pas de // séquence dans ce système), choisie explicitement par l'utilisateur au // même titre que pour la saisie des notes (voir PrimaryComponentNote et // PrimaryEvaluation). Le trimestre est accessible via getQuarter(). #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?PrimaryEvaluation $evaluation = null; // "type" explicite requis (comme Absence/Late::$startTime) : sans lui // Doctrine mappe la colonne en "string" par défaut, et l'insertion plante // avec "Object of class DateTime could not be converted to string" dès // qu'on persiste un DateTime brut ici. #[ORM\Column(type: Types::DATETIME_MUTABLE)] private ?\DateTimeInterface $startAt = null; // Nullable : null = élève toujours absent, heure de retour pas encore // connue/saisie (cas normal juste après l'appel). Voir isReturned(). #[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)] private ?\DateTimeInterface $endAt = null; #[ORM\Column] private bool $justified = false; #[ORM\Column(length: 255, nullable: true)] private ?string $motif = null; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?School $school = null; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?SchoolYear $year = null; #[ORM\ManyToOne] #[ORM\JoinColumn(nullable: false)] private ?User $author = null; public function getId(): ?int { return $this->id; } public function getStudent(): ?Student { return $this->student; } public function setStudent(?Student $student): static { $this->student = $student; return $this; } public function getClasse(): ?TheClass { return $this->classe; } public function setClasse(?TheClass $classe): static { $this->classe = $classe; return $this; } public function getEvaluation(): ?PrimaryEvaluation { return $this->evaluation; } public function setEvaluation(?PrimaryEvaluation $evaluation): static { $this->evaluation = $evaluation; return $this; } public function getQuarter(): ?Quarter { return $this->evaluation?->getQuarter(); } public function getStartAt(): ?\DateTimeInterface { return $this->startAt; } public function setStartAt(\DateTimeInterface $startAt): static { $this->startAt = $startAt; return $this; } public function getEndAt(): ?\DateTimeInterface { return $this->endAt; } public function setEndAt(?\DateTimeInterface $endAt): static { $this->endAt = $endAt; return $this; } /** Heure de retour déjà saisie ? Sinon l'élève est toujours compté absent. */ public function isReturned(): bool { return $this->endAt !== null; } public function isJustified(): bool { return $this->justified; } public function setJustified(bool $justified): static { $this->justified = $justified; return $this; } public function getMotif(): ?string { return $this->motif; } public function setMotif(?string $motif): static { $this->motif = $motif; return $this; } public function getSchool(): ?School { return $this->school; } public function setSchool(?School $school): static { $this->school = $school; return $this; } public function getYear(): ?SchoolYear { return $this->year; } public function setYear(?SchoolYear $year): static { $this->year = $year; return $this; } public function getAuthor(): ?User { return $this->author; } public function setAuthor(?User $author): static { $this->author = $author; return $this; }}