<?php
namespace App\Entity;
use App\Repository\PackageRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: PackageRepository::class)]
class Package
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255, unique: true)]
private $code;
#[ORM\Column(type: 'float', nullable: true)]
private $prix;
#[ORM\Column(type: 'integer')]
private $type;
#[ORM\Column(type: 'integer', nullable: true)]
private $duree;
#[ORM\Column(type: 'integer')]
private $min;
#[ORM\Column(type: 'boolean')]
private $status;
#[ORM\JoinColumn(nullable: false)]
#[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'packages')]
private $user;
#[ORM\Column(type: 'datetime')]
private $created_at;
#[ORM\Column(type: 'datetime', nullable: true)]
private $updated_at;
#[ORM\Column(type: 'text', nullable: true)]
private $description;
#[ORM\ManyToMany(targetEntity: ProgrammeFormation::class)]
private $programmes;
#[ORM\Column(type: 'string', length: 255)]
private $titre;
#[ORM\OneToMany(targetEntity: Souscription::class, mappedBy: 'package')]
private $souscriptions;
const TYPE_LIST_FULL = ["News","Events","Vidéo","Pack formation"],
DUREE_LIST = ['Mensuelle','Annuelle']
;
public function __construct()
{
$this->formations = new ArrayCollection();
$this->created_at = new \DateTime();
$this->status = false;
$this->programmes = new ArrayCollection();
$this->souscriptions = new ArrayCollection();
}
public function getFullType(): ?string
{
return self::TYPE_LIST_FULL[$this->type];
}
public function getFullDuree(): ?string
{
return self::DUREE_LIST[$this->duree];
}
public function getId(): ?int
{
return $this->id;
}
public function getCode(): ?string
{
return $this->code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function getPrix(): ?float
{
return $this->prix;
}
public function setPrix(?float $prix): self
{
$this->prix = $prix;
return $this;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getDuree(): ?int
{
return $this->duree;
}
public function setDuree(?int $duree): self
{
$this->duree = $duree;
return $this;
}
public function getMin(): ?int
{
return $this->min;
}
public function setMin(int $min): self
{
$this->min = $min;
return $this;
}
public function getStatus(): ?bool
{
return $this->status;
}
public function setStatus(bool $status): self
{
$this->status = $status;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at): self
{
$this->created_at = $created_at;
return $this;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updated_at;
}
public function setUpdatedAt(?\DateTimeInterface $updated_at): self
{
$this->updated_at = $updated_at;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
/**
* @return Collection|ProgrammeFormation[]
*/
public function getProgrammes(): Collection
{
return $this->programmes;
}
public function addProgramme(ProgrammeFormation $programme): self
{
if (!$this->programmes->contains($programme)) {
$this->programmes[] = $programme;
}
return $this;
}
public function removeProgramme(ProgrammeFormation $programme): self
{
if ($this->programmes->contains($programme)) {
$this->programmes->removeElement($programme);
}
return $this;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(string $titre): self
{
$this->titre = $titre;
return $this;
}
/**
* @return Collection|Souscription[]
*/
public function getSouscriptions(): Collection
{
return $this->souscriptions;
}
public function addSouscription(Souscription $souscription): self
{
if (!$this->souscriptions->contains($souscription)) {
$this->souscriptions[] = $souscription;
$souscription->setPackage($this);
}
return $this;
}
public function removeSouscription(Souscription $souscription): self
{
if ($this->souscriptions->removeElement($souscription)) {
// set the owning side to null (unless already changed)
if ($souscription->getPackage() === $this) {
$souscription->setPackage(null);
}
}
return $this;
}
}