<?php

namespace App\Entity;

use App\Repository\PanierRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: PanierRepository::class)]
class Panier
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    private ?int $id = null;

    #[ORM\Column(type: Types::DATE_MUTABLE)]
    private ?\DateTimeInterface $date_panier = null;

    #[ORM\Column(length: 255)]
    private ?string $statut = null;

    /**
     * @var Collection<int, ObjetPanier>
     */
    #[ORM\OneToMany(targetEntity: ObjetPanier::class, mappedBy: 'panier')]
    private Collection $objetPaniers;

    #[ORM\ManyToOne(inversedBy: 'paniers')]
    private ?User $user = null;

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

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

    public function getDatePanier(): ?\DateTimeInterface
    {
        return $this->date_panier;
    }

    public function setDatePanier(\DateTimeInterface $date_panier): static
    {
        $this->date_panier = $date_panier;

        return $this;
    }

    public function getStatut(): ?string
    {
        return $this->statut;
    }

    public function setStatut(string $statut): static
    {
        $this->statut = $statut;

        return $this;
    }

    /**
     * @return Collection<int, ObjetPanier>
     */
    public function getObjetPaniers(): Collection
    {
        return $this->objetPaniers;
    }

    public function addObjetPanier(ObjetPanier $objetPanier): static
    {
        if (!$this->objetPaniers->contains($objetPanier)) {
            $this->objetPaniers->add($objetPanier);
            $objetPanier->setPanier($this);
        }

        return $this;
    }

    public function removeObjetPanier(ObjetPanier $objetPanier): static
    {
        if ($this->objetPaniers->removeElement($objetPanier)) {
            // set the owning side to null (unless already changed)
            if ($objetPanier->getPanier() === $this) {
                $objetPanier->setPanier(null);
            }
        }

        return $this;
    }

    public function getUser(): ?User
    {
        return $this->user;
    }

    public function setUser(?User $user): static
    {
        $this->user = $user;

        return $this;
    }
}
