src/Entity/Project.php line 12

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\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. #[ORM\Entity(repositoryClassProjectRepository::class)]
  9. class Project
  10. {
  11.     #[ORM\Id]
  12.     #[ORM\GeneratedValue]
  13.     #[ORM\Column]
  14.     private ?int $id null;
  15.     #[ORM\Column(length150)]
  16.     private ?string $name null;
  17.     #[ORM\Column(typeTypes::TEXT)]
  18.     private ?string $description null;
  19.     #[ORM\OneToMany(mappedBy'project'targetEntityDonation::class)]
  20.     private Collection $donations;
  21.     #[ORM\Column(options: ['default' => 1])]
  22.     private ?bool $active null;
  23.     #[ORM\OneToOne(cascade: ['persist''remove'])]
  24.     private ?FileProjectImage $picture null;
  25.     public function __construct()
  26.     {
  27.         $this->donations = new ArrayCollection();
  28.     }
  29.     public function __toString(): string
  30.     {
  31.         return $this->getName();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     public function getName(): ?string
  38.     {
  39.         return $this->name;
  40.     }
  41.     public function setName(string $name): self
  42.     {
  43.         $this->name $name;
  44.         return $this;
  45.     }
  46.     public function getDescription(): ?string
  47.     {
  48.         return $this->description;
  49.     }
  50.     public function setDescription(string $description): self
  51.     {
  52.         $this->description $description;
  53.         return $this;
  54.     }
  55.     /**
  56.      * @return Collection<int, Donation>
  57.      */
  58.     public function getDonations(): Collection
  59.     {
  60.         return $this->donations;
  61.     }
  62.     public function addDonation(Donation $donation): self
  63.     {
  64.         if (!$this->donations->contains($donation)) {
  65.             $this->donations->add($donation);
  66.             $donation->setProject($this);
  67.         }
  68.         return $this;
  69.     }
  70.     public function removeDonation(Donation $donation): self
  71.     {
  72.         if ($this->donations->removeElement($donation)) {
  73.             // set the owning side to null (unless already changed)
  74.             if ($donation->getProject() === $this) {
  75.                 $donation->setProject(null);
  76.             }
  77.         }
  78.         return $this;
  79.     }
  80.     public function isActive(): ?bool
  81.     {
  82.         return $this->active;
  83.     }
  84.     public function setActive(bool $active): self
  85.     {
  86.         $this->active $active;
  87.         return $this;
  88.     }
  89.     public function getPicture(): ?FileProjectImage
  90.     {
  91.         return $this->picture;
  92.     }
  93.     public function setPicture(?FileProjectImage $picture): self
  94.     {
  95.         $this->picture $picture;
  96.         return $this;
  97.     }
  98. }