<?php
namespace App\Entity;
use App\Repository\NoteRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: NoteRepository::class)]
class Note
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $organization;
#[ORM\Column(type: 'string', length: 255)]
private $education;
#[ORM\Column(type: 'text', nullable: true)]
private $comment;
#[ORM\OneToOne(targetEntity: Booking::class, inversedBy: 'note', cascade: ['persist', 'remove'])]
private $booking;
#[ORM\ManyToOne(targetEntity: ProInfo::class, inversedBy: 'notes')]
private $pro;
#[ORM\Column(type: 'datetime')]
private $createdAt;
#[ORM\ManyToMany(targetEntity: User::class, inversedBy: 'notes')]
private Collection $associatedPros;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $response = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $repliedAt = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $lastReminder = null;
#[ORM\ManyToOne(inversedBy: 'notes')]
private ?Course $course = null;
#[ORM\ManyToOne(inversedBy: 'notes')]
private ?Trainee $trainee = null;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
private ?NoteRequest $noteRequest = null;
public function __construct()
{
$this->associatedPros = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getOrganization(): ?string
{
return $this->organization;
}
public function setOrganization(string $organization): self
{
$this->organization = $organization;
return $this;
}
public function getEducation(): ?string
{
return $this->education;
}
public function setEducation(string $education): self
{
$this->education = $education;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getBooking(): ?Booking
{
return $this->booking;
}
public function setBooking(?Booking $booking): self
{
$this->booking = $booking;
return $this;
}
public function getPro(): ?ProInfo
{
return $this->pro;
}
public function setPro(?ProInfo $pro): self
{
$this->pro = $pro;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getTotalNote()
{
$total = 0;
$number = 0;
$total += $this->getOrganization();
$number++;
$total += $this->getEducation();
$number++;
if ($number != 0) {
$average = number_format((float)($total / $number), 1, '.', '');
return $average;
}
else
{
return null;
}
}
/**
* @return Collection<int, User>
*/
public function getAssociatedPros(): Collection
{
return $this->associatedPros;
}
public function addAssociatedPro(User $associatedPro): static
{
if (!$this->associatedPros->contains($associatedPro)) {
$this->associatedPros->add($associatedPro);
}
return $this;
}
public function removeAssociatedPro(User $associatedPro): static
{
$this->associatedPros->removeElement($associatedPro);
return $this;
}
public function getResponse(): ?string
{
return $this->response;
}
public function setResponse(?string $response): static
{
$this->response = $response;
return $this;
}
public function getRepliedAt(): ?\DateTimeInterface
{
return $this->repliedAt;
}
public function setRepliedAt(?\DateTimeInterface $repliedAt): static
{
$this->repliedAt = $repliedAt;
return $this;
}
public function getLastReminder(): ?\DateTimeInterface
{
return $this->lastReminder;
}
public function setLastReminder(?\DateTimeInterface $lastReminder): static
{
$this->lastReminder = $lastReminder;
return $this;
}
public function getCourse(): ?Course
{
return $this->course;
}
public function setCourse(?Course $course): static
{
$this->course = $course;
return $this;
}
public function getTrainee(): ?Trainee
{
return $this->trainee;
}
public function setTrainee(?Trainee $trainee): static
{
$this->trainee = $trainee;
return $this;
}
public function getNoteRequest(): ?NoteRequest
{
return $this->noteRequest;
}
public function setNoteRequest(?NoteRequest $noteRequest): static
{
$this->noteRequest = $noteRequest;
return $this;
}
}