src/Entity/Dashboard.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity(repositoryClass="App\Repository\DashboardRepository")
  8.  */
  9. class Dashboard
  10. {
  11.     /**
  12.      * @ORM\Id()
  13.      * @ORM\GeneratedValue()
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private $id;
  17.     /**
  18.      * @ORM\OneToOne(targetEntity="App\Entity\User", inversedBy="dashboard")
  19.      */
  20.     private $user;
  21.     /**
  22.      * @ORM\OneToMany(targetEntity="App\Entity\DashboardWidget", mappedBy="dashboard")
  23.      */
  24.     private $dashboardWidgets;
  25.     public function __construct()
  26.     {
  27.         $this->dashboardWidgets = new ArrayCollection();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     /**
  34.      * @return mixed
  35.      */
  36.     public function getUser()
  37.     {
  38.         return $this->user;
  39.     }
  40.     /**
  41.      * @param mixed $user
  42.      */
  43.     public function setUser($user): void
  44.     {
  45.         $this->user $user;
  46.     }
  47.     /**
  48.      * @return Collection|DashboardTemplate[]
  49.      */
  50.     public function getDashboardWidgets(): Collection
  51.     {
  52.         return $this->dashboardWidgets;
  53.     }
  54.     public function addDashboardWidget(DashboardWidget $dashboardWidget): self
  55.     {
  56.         if (!$this->dashboardWidgets->contains($dashboardWidget)) {
  57.             $this->dashboardWidgets->add($dashboardWidget);
  58.             $dashboardWidget->setDashboard($this);
  59.         }
  60.         return $this;
  61.     }
  62.     public function removeDashboardWidget(DashboardWidget $dashboardWidget): self
  63.     {
  64.         if ($this->dashboardWidgets->contains($dashboardWidget)) {
  65.             $this->dashboardWidgets->removeElement($dashboardWidget);
  66.         }
  67.         return $this;
  68.     }
  69. }