src/Entity/Objective.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ObjectiveRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=ObjectiveRepository::class)
  9.  */
  10. class Objective
  11. {
  12.     /**
  13.      * @ORM\Id
  14.      * @ORM\GeneratedValue
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity=Goal::class, inversedBy="objectives")
  20.      * @ORM\JoinColumn(nullable=false)
  21.      */
  22.     private $goal;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $name;
  27.     /**
  28.      * @ORM\OneToMany(targetEntity=Project::class, mappedBy="objective")
  29.      */
  30.     private $projects;
  31.     public function __construct()
  32.     {
  33.         $this->projects = new ArrayCollection();
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getGoal(): ?Goal
  40.     {
  41.         return $this->goal;
  42.     }
  43.     public function setGoal(?Goal $goal): self
  44.     {
  45.         $this->goal $goal;
  46.         return $this;
  47.     }
  48.     public function getName(): ?string
  49.     {
  50.         return $this->name;
  51.     }
  52.     public function setName(string $name): self
  53.     {
  54.         $this->name $name;
  55.         return $this;
  56.     }
  57.     /**
  58.      * @return Collection|Project[]
  59.      */
  60.     public function getProjects(): Collection
  61.     {
  62.         return $this->projects;
  63.     }
  64.     public function addProject(Project $project): self
  65.     {
  66.         if (!$this->projects->contains($project)) {
  67.             $this->projects[] = $project;
  68.             $project->setObjective($this);
  69.         }
  70.         return $this;
  71.     }
  72.     public function removeProject(Project $project): self
  73.     {
  74.         if ($this->projects->removeElement($project)) {
  75.             // set the owning side to null (unless already changed)
  76.             if ($project->getObjective() === $this) {
  77.                 $project->setObjective(null);
  78.             }
  79.         }
  80.         return $this;
  81.     }
  82.     public function __toString()
  83.     {
  84.         return $this->name;
  85.     }
  86. }