<?php
namespace App\Entity;
use App\Repository\ServiceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ServiceRepository::class)]
class Service
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[Assert\NotBlank()]
#[ORM\Column(type: 'date')]
private $date;
#[Assert\NotBlank()]
#[ORM\Column(type: 'datetime_immutable')]
private $debutService;
#[Assert\NotBlank()]
#[ORM\Column(type: 'datetime_immutable')]
private $finService;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: Menu::class, orphanRemoval: true)]
private $menus;
#[Assert\NotBlank()]
#[ORM\ManyToOne(targetEntity: Emplacement::class, inversedBy:'services')]
#[ORM\JoinColumn(nullable:false)]
private $emplacement = null;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: Commande::class, orphanRemoval: true)]
private $commandes;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: Retrait::class, orphanRemoval: true)]
private $retraits;
#[Assert\NotBlank()]
#[ORM\ManyToOne(targetEntity:Foodtruck::class, inversedBy: 'services')]
#[ORM\JoinColumn(nullable: false)]
private $foodtruck;
#[ORM\Column(nullable: true)]
private ?bool $ouvert = false;
#[ORM\Column(nullable: true)]
private ?bool $commandable = true;
#[ORM\Column(nullable: true)]
private ?bool $quantiteVisible = true;
#[ORM\Column(nullable: true)]
private ?bool $prixVisible = true;
public function __toString()
{
return 'Service n° '.$this->id.' du '.$this->date->format('d/m/Y');
}
public function __construct()
{
$this->menus = new ArrayCollection();
$this->commandes = new ArrayCollection();
$this->retraits = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDate(): ?\DateTimeInterface
{
return $this->date;
}
public function setDate(\DateTimeInterface $date): self
{
$this->date = $date;
return $this;
}
public function getDebutService(): ?\DateTimeInterface
{
return $this->debutService;
}
public function setDebutService(\DateTimeInterface $debutService): self
{
$this->debutService = $debutService;
return $this;
}
public function getFinService(): ?\DateTimeInterface
{
return $this->finService;
}
public function setFinService(\DateTimeInterface $finService): self
{
$this->finService = $finService;
return $this;
}
/**
* @return Collection<int, Menu>
*/
public function getMenus(): Collection
{
return $this->menus;
}
public function addMenu(Menu $menu): self
{
if (!$this->menus->contains($menu)) {
$this->menus->add($menu);
$menu->setService($this);
}
return $this;
}
public function removeMenu(Menu $menu): self
{
if ($this->menus->removeElement($menu)) {
// set the owning side to null (unless already changed)
if ($menu->getService() === $this) {
$menu->setService(null);
}
}
return $this;
}
public function getEmplacement(): ?Emplacement
{
return $this->emplacement;
}
public function setEmplacement(?Emplacement $emplacement): self
{
$this->emplacement = $emplacement;
return $this;
}
/**
* @return Collection<int, Commande>
*/
public function getCommandes(): Collection
{
return $this->commandes;
}
public function addCommande(Commande $commande): self
{
if (!$this->commandes->contains($commande)) {
$this->commandes->add($commande);
$commande->setService($this);
}
return $this;
}
public function removeCommande(Commande $commande): self
{
if ($this->commandes->removeElement($commande)) {
// set the owning side to null (unless already changed)
if ($commande->getService() === $this) {
$commande->setService(null);
}
}
return $this;
}
/**
* @return Collection<int, Retrait>
*/
public function getRetraits(): Collection
{
return $this->retraits;
}
public function addRetrait(Retrait $retrait): self
{
if (!$this->retraits->contains($retrait)) {
$this->retraits->add($retrait);
$retrait->setService($this);
}
return $this;
}
public function removeRetrait(Retrait $retrait): self
{
if ($this->retraits->removeElement($retrait)) {
// set the owning side to null (unless already changed)
if ($retrait->getService() === $this) {
$retrait->setService(null);
}
}
return $this;
}
public function getFoodtruck(): ?Foodtruck
{
return $this->foodtruck;
}
public function setFoodtruck(?Foodtruck $foodtruck): self
{
$this->foodtruck = $foodtruck;
return $this;
}
public function isOuvert(): ?bool
{
return $this->ouvert;
}
public function setOuvert(?bool $ouvert): self
{
$this->ouvert = $ouvert;
return $this;
}
public function isCommandable(): ?bool
{
return $this->commandable;
}
public function setCommandable(?bool $commandable): static
{
$this->commandable = $commandable;
return $this;
}
public function isQuantiteVisible(): ?bool
{
return $this->quantiteVisible;
}
public function setQuantiteVisible(?bool $quantiteVisible): static
{
$this->quantiteVisible = $quantiteVisible;
return $this;
}
public function isPrixVisible(): ?bool
{
return $this->prixVisible;
}
public function setPrixVisible(?bool $prixVisible): static
{
$this->prixVisible = $prixVisible;
return $this;
}
}