<?php
namespace App\Entity;
use App\Repository\ProjectRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Form\FormTypeInterface;
use Symfony\Component\Serializer\Annotation\Groups;
#[ORM\Entity(repositoryClass: ProjectRepository::class)]
class Project
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(["getTimes", "getClient", "getProject", "getReservation"])]
private ?int $id = null;
#[ORM\Column(length: 45)]
#[Groups(["getTimes", "getClient", "getProject", "getReservation"])]
private ?string $name = null;
#[ORM\Column]
#[Groups(["getTimes", "getClient", "getProject"])]
private ?bool $active = null;
#[ORM\OneToMany(mappedBy: 'project', targetEntity: Time::class)]
private Collection $times;
#[ORM\ManyToMany(targetEntity: User::class, mappedBy: 'projects')]
private Collection $users;
#[ORM\ManyToOne(inversedBy: 'projects')]
#[ORM\JoinColumn(nullable: false)]
#[Groups(["getProject", "getReservation", "getTimes"])]
private ?Client $client = null;
#[ORM\ManyToOne]
#[Groups(["getProject"])]
private ?TagOrg $favoriteOrgTag = null;
#[ORM\ManyToOne]
#[Groups(["getProject"])]
private ?TagType $favoriteTypeTag = null;
#[ORM\Column(length: 255, nullable: true)]
#[Groups(["getProject"])]
private ?string $driveUrl = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $token = null;
// #[ORM\Column(length: 255, nullable: true)]
// private ?string $token = null;
public function __construct()
{
$this->times = new ArrayCollection();
$this->users = new ArrayCollection();
}
public function __toString(): string
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function isActive(): ?bool
{
return $this->active;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
/**
* @return Collection<int, Time>
*/
public function getTimes(): Collection
{
return $this->times;
}
public function addTime(Time $time): self
{
if (!$this->times->contains($time)) {
$this->times->add($time);
$time->setProject($this);
}
return $this;
}
public function removeTime(Time $time): self
{
if ($this->times->removeElement($time)) {
// set the owning side to null (unless already changed)
if ($time->getProject() === $this) {
$time->setProject(null);
}
}
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->add($user);
$user->addProject($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->removeElement($user)) {
$user->removeProject($this);
}
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setClient(?Client $client): self
{
$this->client = $client;
return $this;
}
public function getFavoriteOrgTag(): ?TagOrg
{
return $this->favoriteOrgTag;
}
public function setFavoriteOrgTag(?TagOrg $favoriteOrgTag): self
{
$this->favoriteOrgTag = $favoriteOrgTag;
return $this;
}
public function getFavoriteTypeTag(): ?TagType
{
return $this->favoriteTypeTag;
}
public function setFavoriteTypeTag(?TagType $favoriteTypeTag): self
{
$this->favoriteTypeTag = $favoriteTypeTag;
return $this;
}
public function getDriveUrl(): ?string
{
return $this->driveUrl;
}
public function setDriveUrl(?string $driveUrl): static
{
$this->driveUrl = $driveUrl;
return $this;
}
public function getToken(): ?string
{
return $this->token;
}
public function setToken(?string $token): static
{
$this->token = $token;
return $this;
}
}