<?php

namespace App\Entity;

use App\Repository\ConseilRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;

/**
 * @ORM\Entity(repositoryClass=ConseilRepository::class)
 * @ORM\Table(schema="sav")
 */
class Conseil
{
    /**
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     * @Groups({"api"})
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=250, nullable=true)
     * @Groups({"api"})
     */
    private $libelle;

    /**
     * @ORM\ManyToOne(targetEntity=TypeConseil::class, inversedBy="conseils")
     * @ORM\JoinColumn(name="idtype_conseil")
     * @Groups({"api"})
     */
    private $type_conseil;

    /**
     * @ORM\OneToMany(targetEntity=AttestationEntretienConseil::class, mappedBy="conseil")
     */
    private $attestationEntretienConseils;

    public function __construct()
    {
        $this->attestationEntretienConseils = new ArrayCollection();
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function setId(?int $id): self
    {
        $this->id = $id;

        return $this;
    }

    public function getLibelle(): ?string
    {
        return $this->libelle;
    }

    public function setLibelle(?string $libelle): self
    {
        $this->libelle = $libelle;

        return $this;
    }

    public function getTypeConseil(): ?TypeConseil
    {
        return $this->type_conseil;
    }

    public function setTypeConseil(?TypeConseil $type_conseil): self
    {
        $this->type_conseil = $type_conseil;

        return $this;
    }

    /**
     * @return Collection<int, AttestationEntretienConseil>
     */
    public function getAttestationEntretienConseils(): Collection
    {
        return $this->attestationEntretienConseils;
    }

    public function addAttestationEntretienConseil(AttestationEntretienConseil $attestationEntretienConseil): self
    {
        if (!$this->attestationEntretienConseils->contains($attestationEntretienConseil)) {
            $this->attestationEntretienConseils[] = $attestationEntretienConseil;
            $attestationEntretienConseil->setConseil($this);
        }

        return $this;
    }

    public function removeAttestationEntretienConseil(AttestationEntretienConseil $attestationEntretienConseil): self
    {
        if ($this->attestationEntretienConseils->removeElement($attestationEntretienConseil)) {
            // set the owning side to null (unless already changed)
            if ($attestationEntretienConseil->getConseil() === $this) {
                $attestationEntretienConseil->setConseil(null);
            }
        }

        return $this;
    }
}
