src/Entity/Project.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProjectRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClassProjectRepository::class)]
  8. class Project
  9. {
  10.     #[ORM\Id]
  11.     #[ORM\GeneratedValue]
  12.     #[ORM\Column]
  13.     private ?int $id null;
  14.     #[ORM\Column(length255)]
  15.     private ?string $name null;
  16.     #[ORM\Column(length255nullabletrue)]
  17.     private ?string $logo null;
  18.     #[ORM\Column]
  19.     private ?bool $catalogAllowed null;
  20.     #[ORM\Column]
  21.     private ?\DateTime $lastUpdated null;
  22.     #[ORM\Column]
  23.     private ?int $last_update_alert null;
  24.     #[ORM\Column]
  25.     private array $competitors = [];
  26.     #[ORM\Column]
  27.     private ?bool $isActive null;
  28.     #[ORM\OneToMany(mappedBy'project'targetEntityUserProject::class, cascade: ['persist''remove'])]
  29.     private Collection $userProjects;
  30.     public function __construct()
  31.     {
  32.         $this->userProjects = new ArrayCollection();
  33.     }
  34.     public function getId(): ?int
  35.     {
  36.         return $this->id;
  37.     }
  38.     public function getName(): ?string
  39.     {
  40.         return $this->name;
  41.     }
  42.     public function setName(string $name): static
  43.     {
  44.         $this->name $name;
  45.         return $this;
  46.     }
  47.     public function isCatalogAllowed(): ?bool
  48.     {
  49.         return $this->catalogAllowed;
  50.     }
  51.     public function setCatalogAllowed(bool $catalogAllowed): static
  52.     {
  53.         $this->catalogAllowed $catalogAllowed;
  54.         return $this;
  55.     }
  56.     public function getUserProjects(): Collection
  57.     {
  58.         return $this->userProjects;
  59.     }
  60.     public function addUser(User $userRole $role): self
  61.     {
  62.         foreach ($this->userProjects as $userProject) {
  63.             if ($userProject->getUser() === $user) {
  64.                 return $this;
  65.             }
  66.         }
  67.         $userProject = new UserProject($user$this, [$role]);
  68.         $this->userProjects->add($userProject);
  69.         return $this;
  70.     }
  71.     public function removeUser(User $user): self
  72.     {
  73.         foreach ($this->userProjects as $userProject) {
  74.             if ($userProject->getUser() === $user) {
  75.                 $this->userProjects->removeElement($userProject);
  76.             }
  77.         }
  78.         return $this;
  79.     }
  80.     public function __toString(): string
  81.     {
  82.         return $this->getName();
  83.     }
  84.     public function addUserProject(UserProject $userProject): static
  85.     {
  86.         if (!$this->userProjects->contains($userProject)) {
  87.             $this->userProjects->add($userProject);
  88.             $userProject->setProject($this);
  89.         }
  90.         return $this;
  91.     }
  92.     public function removeUserProject(UserProject $userProject): static
  93.     {
  94.         if ($this->userProjects->removeElement($userProject)) {
  95.             // set the owning side to null (unless already changed)
  96.             if ($userProject->getProject() === $this) {
  97.                 $userProject->setProject(null);
  98.             }
  99.         }
  100.         return $this;
  101.     }
  102.     public function isIsActive(): ?bool
  103.     {
  104.         return $this->isActive;
  105.     }
  106.     public function setIsActive(bool $isActive): static
  107.     {
  108.         $this->isActive $isActive;
  109.         return $this;
  110.     }
  111.     public function getLastUpdated(): ?\DateTimeInterface
  112.     {
  113.         return $this->lastUpdated;
  114.     }
  115.     public function setLastUpdated(\DateTime $lastUpdated): static
  116.     {
  117.         $this->lastUpdated $lastUpdated;
  118.         return $this;
  119.     }
  120.     public function getLastUpdateAlert(): ?int
  121.     {
  122.         return $this->last_update_alert;
  123.     }
  124.     public function setLastUpdateAlert(int $last_update_alert): static
  125.     {
  126.         $this->last_update_alert $last_update_alert;
  127.         return $this;
  128.     }
  129.     public function getCompetitors(): array
  130.     {
  131.         return $this->competitors;
  132.     }
  133.     public function setCompetitors(array $competitors): static
  134.     {
  135.         $this->competitors $competitors;
  136.         return $this;
  137.     }
  138.     public function getLogo(): ?string
  139.     {
  140.         return $this->logo;
  141.     }
  142.     public function setLogo(?string $logo): static
  143.     {
  144.         $this->logo $logo;
  145.         return $this;
  146.     }
  147. }