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

420 lines
9.6 KiB
PHP

<?php
namespace App\Entity;
use App\Repository\ArticleRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ArticleRepository::class)]
class Article
{
#[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 quantité'=> 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_quantite = 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\ManyToOne(inversedBy: 'articles')]
#[ORM\JoinColumn(nullable: false)]
private ?Societe $societe = null;
#[ORM\Column]
private ?bool $active = null;
#[ORM\ManyToOne(inversedBy: 'articles')]
#[ORM\JoinColumn(nullable: false)]
private ?Categorie $categorie = null;
#[ORM\ManyToOne(inversedBy: 'articles')]
#[ORM\JoinColumn(nullable: false)]
private ?User $create_by = null;
#[ORM\OneToMany(mappedBy: 'article', targetEntity: ReservationArticle::class)]
private Collection $reservationArticles;
#[ORM\OneToMany(mappedBy: 'article', targetEntity: CommentArticle::class)]
#[ORM\OrderBy(['id' => 'DESC'])]
private Collection $commentArticles;
public function __construct()
{
$this->active = false;
$this->date_add = new \DateTime();
$this->date_update = new \DateTime();
$this->reservationArticles = new ArrayCollection();
$this->commentArticles = 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 getLimitQuantite(): ?int
{
return $this->limit_quantite;
}
public function setLimitQuantite(?int $limit_quantite): static
{
$this->limit_quantite = $limit_quantite;
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 getSociete(): ?Societe
{
return $this->societe;
}
public function setSociete(?Societe $societe): static
{
$this->societe = $societe;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): static
{
$this->active = $active;
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, ReservationArticle>
*/
public function getReservationArticles(): Collection
{
return $this->reservationArticles;
}
public function addReservationArticle(ReservationArticle $reservationArticle): static
{
if (!$this->reservationArticles->contains($reservationArticle)) {
$this->reservationArticles->add($reservationArticle);
$reservationArticle->setArticle($this);
}
return $this;
}
public function removeReservationArticle(ReservationArticle $reservationArticle): static
{
if ($this->reservationArticles->removeElement($reservationArticle)) {
// set the owning side to null (unless already changed)
if ($reservationArticle->getArticle() === $this) {
$reservationArticle->setArticle(null);
}
}
return $this;
}
/**
* @return Collection<int, CommentArticle>
*/
public function getCommentArticles(): Collection
{
return $this->commentArticles;
}
public function addCommentArticle(CommentArticle $commentArticle): static
{
if (!$this->commentArticles->contains($commentArticle)) {
$this->commentArticles->add($commentArticle);
$commentArticle->setArticle($this);
}
return $this;
}
public function removeCommentArticle(CommentArticle $commentArticle): static
{
if ($this->commentArticles->removeElement($commentArticle)) {
// set the owning side to null (unless already changed)
if ($commentArticle->getArticle() === $this) {
$commentArticle->setArticle(null);
}
}
return $this;
}
}