<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\FormationRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: FormationRepository::class)]
#[ApiResource(normalizationContext: ['groups' => ['Formation_read']])]
class Formation
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['Formation_read'])]
private ?int $id = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $titre = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $prix = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $description = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $contenu = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $affiche = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $duree = null;
#[ORM\Column(length: 255)]
#[Groups(['Formation_read'])]
private ?string $slug = null;
#[ORM\ManyToOne(inversedBy: 'relation')]
#[Groups(['Formation_read'])]
private ?Planification $planification = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $texttt = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $totalinscrit = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $nblike = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $nbavis = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $niveau = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $categorie = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $nbheure = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $desccourt = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(['Formation_read'])]
private ?string $photofront = null;
#[ORM\ManyToOne(inversedBy: 'formations')]
private ?User $formateur = null;
#[ORM\OneToMany(mappedBy: 'formation', targetEntity: Section::class,cascade: ['remove'])]
#[Groups(['Formation_read'])] // 👈 ajouter ceci
private Collection $sections;
#[ORM\OneToMany(mappedBy: 'formation', targetEntity: Evenement::class,cascade: ['remove'])]
private Collection $evenements;
#[ORM\Column(nullable: true)]
#[Groups(['Formation_read'])]
private ?bool $isPopulaire = null;
#[ORM\ManyToMany(targetEntity: Offres::class, mappedBy: 'formation')]
private Collection $offres;
#[ORM\OneToMany(mappedBy: 'formation', targetEntity: Trace::class,cascade: ['remove'])]
private Collection $traces;
public function __construct()
{
$this->sections = new ArrayCollection();
$this->evenements = new ArrayCollection();
$this->offres = new ArrayCollection();
$this->traces = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(?string $titre): self
{
$this->titre = $titre;
return $this;
}
public function getPrix(): ?string
{
return $this->prix;
}
public function setPrix(?string $prix): self
{
$this->prix = $prix;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getContenu(): ?string
{
return $this->contenu;
}
public function setContenu(?string $contenu): self
{
$this->contenu = $contenu;
return $this;
}
public function getAffiche(): ?string
{
return $this->affiche;
}
public function setAffiche(?string $affiche): self
{
$this->affiche = $affiche;
return $this;
}
public function getDuree(): ?string
{
return $this->duree;
}
public function setDuree(?string $duree): self
{
$this->duree = $duree;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getPlanification(): ?Planification
{
return $this->planification;
}
public function setPlanification(?Planification $planification): self
{
$this->planification = $planification;
return $this;
}
public function getTexttt(): ?string
{
return $this->texttt;
}
public function setTexttt(?string $texttt): self
{
$this->texttt = $texttt;
return $this;
}
public function getTotalinscrit(): ?string
{
return $this->totalinscrit;
}
public function setTotalinscrit(?string $totalinscrit): self
{
$this->totalinscrit = $totalinscrit;
return $this;
}
public function getNblike(): ?string
{
return $this->nblike;
}
public function setNblike(?string $nblike): self
{
$this->nblike = $nblike;
return $this;
}
public function getNbavis(): ?string
{
return $this->nbavis;
}
public function setNbavis(?string $nbavis): self
{
$this->nbavis = $nbavis;
return $this;
}
public function getNiveau(): ?string
{
return $this->niveau;
}
public function setNiveau(?string $niveau): self
{
$this->niveau = $niveau;
return $this;
}
public function getCategorie(): ?string
{
return $this->categorie;
}
public function setCategorie(?string $categorie): self
{
$this->categorie = $categorie;
return $this;
}
public function getNbheure(): ?string
{
return $this->nbheure;
}
public function setNbheure(?string $nbheure): self
{
$this->nbheure = $nbheure;
return $this;
}
public function getDesccourt(): ?string
{
return $this->desccourt;
}
public function setDesccourt(?string $desccourt): self
{
$this->desccourt = $desccourt;
return $this;
}
public function getPhotofront(): ?string
{
return $this->photofront;
}
public function setPhotofront(?string $photofront): self
{
$this->photofront = $photofront;
return $this;
}
public function getFormateur(): ?User
{
return $this->formateur;
}
public function setFormateur(?User $formateur): self
{
$this->formateur = $formateur;
return $this;
}
/**
* @return Collection<int, Section>
*/
public function getSections(): Collection
{
return $this->sections;
}
public function addSection(Section $section): self
{
if (!$this->sections->contains($section)) {
$this->sections->add($section);
$section->setFormation($this);
}
return $this;
}
public function removeSection(Section $section): self
{
if ($this->sections->removeElement($section)) {
// set the owning side to null (unless already changed)
if ($section->getFormation() === $this) {
$section->setFormation(null);
}
}
return $this;
}
/**
* @return Collection<int, Evenement>
*/
public function getEvenements(): Collection
{
return $this->evenements;
}
public function addEvenement(Evenement $evenement): self
{
if (!$this->evenements->contains($evenement)) {
$this->evenements->add($evenement);
$evenement->setFormation($this);
}
return $this;
}
public function removeEvenement(Evenement $evenement): self
{
if ($this->evenements->removeElement($evenement)) {
// set the owning side to null (unless already changed)
if ($evenement->getFormation() === $this) {
$evenement->setFormation(null);
}
}
return $this;
}
public function __toString(): string
{
return $this->titre;
}
public function isIsPopulaire(): ?bool
{
return $this->isPopulaire;
}
public function setIsPopulaire(?bool $isPopulaire): self
{
$this->isPopulaire = $isPopulaire;
return $this;
}
/**
* @return Collection<int, Offres>
*/
public function getOffres(): Collection
{
return $this->offres;
}
public function addOffre(Offres $offre): self
{
if (!$this->offres->contains($offre)) {
$this->offres->add($offre);
$offre->addFormation($this);
}
return $this;
}
public function removeOffre(Offres $offre): self
{
if ($this->offres->removeElement($offre)) {
$offre->removeFormation($this);
}
return $this;
}
/**
* @return Collection<int, Trace>
*/
public function getTraces(): Collection
{
return $this->traces;
}
public function addTrace(Trace $trace): self
{
if (!$this->traces->contains($trace)) {
$this->traces->add($trace);
$trace->setFormation($this);
}
return $this;
}
public function removeTrace(Trace $trace): self
{
if ($this->traces->removeElement($trace)) {
// set the owning side to null (unless already changed)
if ($trace->getFormation() === $this) {
$trace->setFormation(null);
}
}
return $this;
}
}