<?php
namespace App\Entity;
use App\Repository\ProjectRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ProjectRepository::class)]
class Project
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
private ?string $name = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $logo = null;
#[ORM\Column]
private ?bool $catalogAllowed = null;
#[ORM\Column]
private ?\DateTime $lastUpdated = null;
#[ORM\Column]
private ?int $last_update_alert = null;
#[ORM\Column]
private array $competitors = [];
#[ORM\Column]
private ?bool $isActive = null;
#[ORM\OneToMany(mappedBy: 'project', targetEntity: UserProject::class, cascade: ['persist', 'remove'])]
private Collection $userProjects;
public function __construct()
{
$this->userProjects = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function isCatalogAllowed(): ?bool
{
return $this->catalogAllowed;
}
public function setCatalogAllowed(bool $catalogAllowed): static
{
$this->catalogAllowed = $catalogAllowed;
return $this;
}
public function getUserProjects(): Collection
{
return $this->userProjects;
}
public function addUser(User $user, Role $role): self
{
foreach ($this->userProjects as $userProject) {
if ($userProject->getUser() === $user) {
return $this;
}
}
$userProject = new UserProject($user, $this, [$role]);
$this->userProjects->add($userProject);
return $this;
}
public function removeUser(User $user): self
{
foreach ($this->userProjects as $userProject) {
if ($userProject->getUser() === $user) {
$this->userProjects->removeElement($userProject);
}
}
return $this;
}
public function __toString(): string
{
return $this->getName();
}
public function addUserProject(UserProject $userProject): static
{
if (!$this->userProjects->contains($userProject)) {
$this->userProjects->add($userProject);
$userProject->setProject($this);
}
return $this;
}
public function removeUserProject(UserProject $userProject): static
{
if ($this->userProjects->removeElement($userProject)) {
// set the owning side to null (unless already changed)
if ($userProject->getProject() === $this) {
$userProject->setProject(null);
}
}
return $this;
}
public function isIsActive(): ?bool
{
return $this->isActive;
}
public function setIsActive(bool $isActive): static
{
$this->isActive = $isActive;
return $this;
}
public function getLastUpdated(): ?\DateTimeInterface
{
return $this->lastUpdated;
}
public function setLastUpdated(\DateTime $lastUpdated): static
{
$this->lastUpdated = $lastUpdated;
return $this;
}
public function getLastUpdateAlert(): ?int
{
return $this->last_update_alert;
}
public function setLastUpdateAlert(int $last_update_alert): static
{
$this->last_update_alert = $last_update_alert;
return $this;
}
public function getCompetitors(): array
{
return $this->competitors;
}
public function setCompetitors(array $competitors): static
{
$this->competitors = $competitors;
return $this;
}
public function getLogo(): ?string
{
return $this->logo;
}
public function setLogo(?string $logo): static
{
$this->logo = $logo;
return $this;
}
}