<?php
namespace App\Entity;
use App\Repository\InterventionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\InterventionRepository", repositoryClass=InterventionRepository::class)
*/
class Intervention
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private ?int $id;
/**
* @ORM\Column(type="datetime")
*/
private ?\DateTimeInterface $createdAt;
/**
* @ORM\Column(type="string", length=255)
*/
private ?string $object;
/**
* @ORM\Column(type="boolean")
*/
private ?bool $distance;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $description;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $numFacture;
/**
* @ORM\Column(type="boolean")
*/
private ?bool $archived;
/**
* @ORM\ManyToOne(targetEntity=User::class)
* @ORM\JoinColumn(nullable=false)
*/
private ?User $creator;
/**
* @ORM\ManyToOne(targetEntity=Customer::class)
* @ORM\JoinColumn(nullable=false)
*/
private ?Customer $customer;
/**
* @ORM\ManyToOne(targetEntity=Contact::class)
* @ORM\JoinColumn(nullable=true)
*/
private ?Contact $contact;
/**
* @ORM\ManyToMany(targetEntity=TypeIntervention::class)
*/
private Collection $typesIntervention;
/**
* @ORM\ManyToMany(targetEntity=Speaker::class, inversedBy="interventions", cascade={"persist"}, orphanRemoval="true")
* @ORM\OrderBy({"createdAt" = "ASC"})
*/
private $speakers;
/**
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="interventionFav")
*/
private $users;
public function __construct()
{
$this->createdAt = new \DateTime(" 00:00:00");
$this->archived = 0;
$this->distance = 0;
$this->typesIntervention = new ArrayCollection();
$this->speakers = new ArrayCollection();
$this->users = new ArrayCollection();
}
// private bool $isFavorite;
//
// /**
// * @return bool
// */
// public function isFavorite(): bool
// {
// return $this->isFavorite;
// }
//
// /**
// * @param bool $isFavorite
// */
// public function setIsFavorite(bool $isFavorite): void
// {
// $this->isFavorite = $isFavorite;
// }
public function getId(): ?int
{
return $this->id;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getObject(): ?string
{
return $this->object;
}
public function setObject(string $object): self
{
$this->object = $object;
return $this;
}
public function getDistance(): ?bool
{
return $this->distance;
}
public function setDistance(bool $distance): self
{
$this->distance = $distance;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getNumFacture(): ?string
{
return $this->numFacture;
}
public function setNumFacture(string $numFacture): self
{
$this->numFacture = $numFacture;
return $this;
}
public function getArchived(): ?bool
{
return $this->archived;
}
public function setArchived(bool $archived): self
{
$this->archived = $archived;
return $this;
}
public function getCreator(): ?User
{
return $this->creator;
}
public function setCreator(?User $creator): self
{
$this->creator = $creator;
return $this;
}
public function getCustomer(): ?Customer
{
return $this->customer;
}
public function setCustomer(?Customer $customer): self
{
$this->customer = $customer;
return $this;
}
public function getContact(): ?Contact
{
return $this->contact;
}
public function setContact(?Contact $contact): self
{
$this->contact = $contact;
return $this;
}
/**
* @return Collection|TypeIntervention[]
*/
public function getTypesIntervention(): Collection
{
return $this->typesIntervention;
}
public function addTypesIntervention(TypeIntervention $typesIntervention): self
{
if (!$this->typesIntervention->contains($typesIntervention)) {
$this->typesIntervention[] = $typesIntervention;
}
return $this;
}
public function removeTypesIntervention(TypeIntervention $typesIntervention): self
{
$this->typesIntervention->removeElement($typesIntervention);
return $this;
}
/**
* @return Collection<int, Speaker>
*/
public function getSpeakers(): Collection
{
return $this->speakers;
}
public function addSpeaker(Speaker $speaker): self
{
if (!$this->speakers->contains($speaker)) {
$this->speakers[] = $speaker;
}
return $this;
}
public function removeSpeaker(Speaker $speaker): self
{
$this->speakers->removeElement($speaker);
return $this;
}
/**
* @return Collection<int, User>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->addInterventionFav($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
$user->removeInterventionFav($this);
}
return $this;
}
}