Files
tn_promo/src/Entity/Service.php
2025-10-30 13:13:41 +01:00

523 lines
12 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\ServiceRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ServiceRepository::class)]
class Service
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $titre = null;
#[ORM\Column(length: 255)]
private ?string $marque = null;
#[ORM\Column(type: Types::TEXT)]
private ?string $description = null;
#[ORM\Column(nullable: true)]
private ?float $prix_marche = null;
#[ORM\Column]
private ?float $prix_promo = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $adress = null;
// 'Limitation par date'=> 0 | 'Limitation par rendez-vous'=> 1
#[ORM\Column(type: Types::SMALLINT)]
private ?int $limit_type = null;
#[ORM\Column(type: Types::DATE_MUTABLE, nullable: true)]
private ?\DateTimeInterface $limit_date = null;
#[ORM\Column(nullable: true)]
private ?int $limit_nbr_rdv = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image_default = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image_detail_1 = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image_detail_2 = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image_detail_3 = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $image_detail_4 = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $date_add = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE)]
private ?\DateTimeInterface $date_update = null;
#[ORM\Column]
private ?bool $active = null;
#[ORM\Column(nullable: false)]
private ?int $duree = null;
#[ORM\ManyToOne(inversedBy: 'services')]
#[ORM\JoinColumn(nullable: false)]
private ?Societe $societe = null;
#[ORM\ManyToOne(inversedBy: 'services')]
#[ORM\JoinColumn(nullable: false)]
private ?Categorie $categorie = null;
#[ORM\ManyToOne(inversedBy: 'services')]
#[ORM\JoinColumn(nullable: false)]
private ?User $create_by = null;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: ServiceRdv::class)]
private Collection $serviceRdvs;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: ServiceRdvReservation::class)]
private Collection $serviceRdvReservations;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: ReservationService::class)]
private Collection $reservationServices;
#[ORM\OneToMany(mappedBy: 'service', targetEntity: CommentService::class)]
#[ORM\OrderBy(['id' => 'DESC'])]
private Collection $commentServices;
public function __construct()
{
$this->active = false;
$this->date_add = new \DateTime();
$this->date_update = new \DateTime();
$this->serviceRdvs = new ArrayCollection();
$this->serviceRdvReservations = new ArrayCollection();
$this->reservationServices = new ArrayCollection();
$this->commentServices = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(string $titre): static
{
$this->titre = $titre;
return $this;
}
public function getMarque(): ?string
{
return $this->marque;
}
public function setMarque(string $marque): static
{
$this->marque = $marque;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): static
{
$this->description = $description;
return $this;
}
public function getPrixMarche(): ?float
{
return $this->prix_marche;
}
public function setPrixMarche(?float $prix_marche): self
{
$this->prix_marche = $prix_marche;
return $this;
}
public function getPrixPromo(): ?float
{
return $this->prix_promo;
}
public function setPrixPromo(float $prix_promo): self
{
$this->prix_promo = $prix_promo;
return $this;
}
public function getAdress(): ?string
{
return $this->adress;
}
public function setAdress(?string $adress): static
{
$this->adress = $adress;
return $this;
}
public function getLimitType(): ?int
{
return $this->limit_type;
}
public function setLimitType(int $limit_type): static
{
$this->limit_type = $limit_type;
return $this;
}
public function getLimitDate(): ?\DateTimeInterface
{
return $this->limit_date;
}
public function setLimitDate(?\DateTimeInterface $limit_date): static
{
$this->limit_date = $limit_date;
return $this;
}
public function getLimitNbrRdv(): ?int
{
return $this->limit_nbr_rdv;
}
public function setLimitNbrRdv(?int $limit_nbr_rdv): static
{
$this->limit_nbr_rdv = $limit_nbr_rdv;
return $this;
}
public function getImageDefault(): ?string
{
return $this->image_default;
}
public function setImageDefault(?string $image_default): static
{
$this->image_default = $image_default;
return $this;
}
public function getImageDetail1(): ?string
{
return $this->image_detail_1;
}
public function setImageDetail1(?string $image_detail_1): static
{
$this->image_detail_1 = $image_detail_1;
return $this;
}
public function getImageDetail2(): ?string
{
return $this->image_detail_2;
}
public function setImageDetail2(?string $image_detail_2): static
{
$this->image_detail_2 = $image_detail_2;
return $this;
}
public function getImageDetail3(): ?string
{
return $this->image_detail_3;
}
public function setImageDetail3(?string $image_detail_3): static
{
$this->image_detail_3 = $image_detail_3;
return $this;
}
public function getImageDetail4(): ?string
{
return $this->image_detail_4;
}
public function setImageDetail4(?string $image_detail_4): static
{
$this->image_detail_4 = $image_detail_4;
return $this;
}
public function getAllImage(): ?array
{
$ListImg = [];
if($this->image_default) $ListImg[] = $this->image_default;
if($this->image_detail_1) $ListImg[] = $this->image_detail_1;
if($this->image_detail_2) $ListImg[] = $this->image_detail_2;
if($this->image_detail_3) $ListImg[] = $this->image_detail_3;
if($this->image_detail_4) $ListImg[] = $this->image_detail_4;
return $ListImg;
}
public function getDateAdd(): ?\DateTimeInterface
{
return $this->date_add;
}
public function setDateAdd(\DateTimeInterface $date_add): static
{
$this->date_add = $date_add;
return $this;
}
public function getDateUpdate(): ?\DateTimeInterface
{
return $this->date_update;
}
public function setDateUpdate(\DateTimeInterface $date_update): static
{
$this->date_update = $date_update;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): static
{
$this->active = $active;
return $this;
}
public function gestionActive(): static
{
if($this->image_default == null){
$this->active = false;
}else{
if($this->limit_type == 0){
if($this->limit_date != null){
$this->active = true;
}else{
$this->active = false;
}
}elseif($this->limit_type == 1){
if($this->limit_nbr_rdv > 1){
$this->active = true;
}else{
$this->active = false;
}
}
}
return $this;
}
public function getDuree(): ?int
{
return $this->duree;
}
public function setDuree(?int $duree): static
{
$this->duree = $duree;
return $this;
}
public function getSociete(): ?Societe
{
return $this->societe;
}
public function setSociete(?Societe $societe): static
{
$this->societe = $societe;
return $this;
}
public function getCategorie(): ?Categorie
{
return $this->categorie;
}
public function setCategorie(?Categorie $categorie): static
{
$this->categorie = $categorie;
return $this;
}
public function getCreateBy(): ?User
{
return $this->create_by;
}
public function setCreateBy(?User $create_by): static
{
$this->create_by = $create_by;
return $this;
}
/**
* @return Collection<int, ServiceRdv>
*/
public function getServiceRdvs(): Collection
{
return $this->serviceRdvs;
}
public function addServiceRdv(ServiceRdv $serviceRdv): static
{
if (!$this->serviceRdvs->contains($serviceRdv)) {
$this->serviceRdvs->add($serviceRdv);
$serviceRdv->setService($this);
}
return $this;
}
public function removeServiceRdv(ServiceRdv $serviceRdv): static
{
if ($this->serviceRdvs->removeElement($serviceRdv)) {
// set the owning side to null (unless already changed)
if ($serviceRdv->getService() === $this) {
$serviceRdv->setService(null);
}
}
return $this;
}
/**
* @return Collection<int, ServiceRdvReservation>
*/
public function getServiceRdvReservations(): Collection
{
return $this->serviceRdvReservations;
}
public function addServiceRdvReservation(ServiceRdvReservation $serviceRdvReservation): static
{
if (!$this->serviceRdvReservations->contains($serviceRdvReservation)) {
$this->serviceRdvReservations->add($serviceRdvReservation);
$serviceRdvReservation->setService($this);
}
return $this;
}
public function removeServiceRdvReservation(ServiceRdvReservation $serviceRdvReservation): static
{
if ($this->serviceRdvReservations->removeElement($serviceRdvReservation)) {
// set the owning side to null (unless already changed)
if ($serviceRdvReservation->getService() === $this) {
$serviceRdvReservation->setService(null);
}
}
return $this;
}
/**
* @return Collection<int, ReservationService>
*/
public function getReservationServices(): Collection
{
return $this->reservationServices;
}
public function addReservationService(ReservationService $reservationService): static
{
if (!$this->reservationServices->contains($reservationService)) {
$this->reservationServices->add($reservationService);
$reservationService->setService($this);
}
return $this;
}
public function removeReservationService(ReservationService $reservationService): static
{
if ($this->reservationServices->removeElement($reservationService)) {
// set the owning side to null (unless already changed)
if ($reservationService->getService() === $this) {
$reservationService->setService(null);
}
}
return $this;
}
/**
* @return Collection<int, CommentService>
*/
public function getCommentServices(): Collection
{
return $this->commentServices;
}
public function addCommentService(CommentService $commentService): static
{
if (!$this->commentServices->contains($commentService)) {
$this->commentServices->add($commentService);
$commentService->setService($this);
}
return $this;
}
public function removeCommentService(CommentService $commentService): static
{
if ($this->commentServices->removeElement($commentService)) {
// set the owning side to null (unless already changed)
if ($commentService->getService() === $this) {
$commentService->setService(null);
}
}
return $this;
}
}