src/Entity/User.php line 14

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. use Sonata\UserBundle\Entity\BaseUser;
  7. /**
  8.  * @ORM\Entity
  9.  * @ORM\Table(name="user")
  10.  */
  11. class User extends BaseUser
  12. {
  13.     const USER_ZSOLT 1;
  14.     /**
  15.      * @var int
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     protected $id;
  21.     /**
  22.      * @var string
  23.      * @ORM\Column(type="string", length=100, unique=true, nullable=true)
  24.      */
  25.     private ?string $name;
  26.     /**
  27.      * @ORM\OneToMany(targetEntity=Task::class, mappedBy="assignedUser")
  28.      */
  29.     private $assignedTasks;
  30.     /**
  31.      * @ORM\OneToMany(targetEntity=TaskLog::class, mappedBy="user", orphanRemoval=true)
  32.      */
  33.     private $taskLogs;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $phone;
  38.     /**
  39.      * @ORM\OneToMany(targetEntity=CashOut::class, mappedBy="user")
  40.      */
  41.     private $cashOuts;
  42.     /**
  43.      * @ORM\OneToMany(targetEntity=AnualLeave::class, mappedBy="userOnHoliday")
  44.      */
  45.     private $userAnualLeavs;
  46.     /**
  47.      * @ORM\Column(type="integer", nullable=true, options={"default":0})
  48.      */
  49.     private ?int $vacationDays 0;
  50.     public function __construct()
  51.     {
  52.         $this->assignedTasks = new ArrayCollection();
  53.         $this->taskLogs = new ArrayCollection();
  54.         $this->cashOuts = new ArrayCollection();
  55.         $this->userAnualLeavs = new ArrayCollection();
  56.     }
  57.     public function getName(): ?string
  58.     {
  59.         return $this->name;
  60.     }
  61.     public function setName(?string $name): void
  62.     {
  63.         $this->name $name;
  64.     }
  65.     /**
  66.      * @return Collection<int, Task>
  67.      */
  68.     public function getAssignedTasks(): Collection
  69.     {
  70.         return $this->assignedTasks;
  71.     }
  72.     public function addAssignedTask(Task $assignedTask): self
  73.     {
  74.         if (!$this->assignedTasks->contains($assignedTask)) {
  75.             $this->assignedTasks[] = $assignedTask;
  76.             $assignedTask->setAssignedUser($this);
  77.         }
  78.         return $this;
  79.     }
  80.     public function removeAssignedTask(Task $assignedTask): self
  81.     {
  82.         if ($this->assignedTasks->removeElement($assignedTask)) {
  83.             // set the owning side to null (unless already changed)
  84.             if ($assignedTask->getAssignedUser() === $this) {
  85.                 $assignedTask->setAssignedUser(null);
  86.             }
  87.         }
  88.         return $this;
  89.     }
  90.     /**
  91.      * @return Collection<int, TaskLog>
  92.      */
  93.     public function getTaskLogs(): Collection
  94.     {
  95.         return $this->taskLogs;
  96.     }
  97.     public function addTaskLog(TaskLog $taskLog): self
  98.     {
  99.         if (!$this->taskLogs->contains($taskLog)) {
  100.             $this->taskLogs[] = $taskLog;
  101.             $taskLog->setUser($this);
  102.         }
  103.         return $this;
  104.     }
  105.     public function removeTaskLog(TaskLog $taskLog): self
  106.     {
  107.         if ($this->taskLogs->removeElement($taskLog)) {
  108.             // set the owning side to null (unless already changed)
  109.             if ($taskLog->getUser() === $this) {
  110.                 $taskLog->setUser(null);
  111.             }
  112.         }
  113.         return $this;
  114.     }
  115.     public function getPhone(): ?string
  116.     {
  117.         return $this->phone;
  118.     }
  119.     public function setPhone(?string $phone): self
  120.     {
  121.         $this->phone $phone;
  122.         return $this;
  123.     }
  124.     /**
  125.      * @return Collection<int, CashOut>
  126.      */
  127.     public function getCashOuts(): Collection
  128.     {
  129.         return $this->cashOuts;
  130.     }
  131.     public function addCashOut(CashOut $cashOut): self
  132.     {
  133.         if (!$this->cashOuts->contains($cashOut)) {
  134.             $this->cashOuts[] = $cashOut;
  135.             $cashOut->setUser($this);
  136.         }
  137.         return $this;
  138.     }
  139.     public function removeCashOut(CashOut $cashOut): self
  140.     {
  141.         if ($this->cashOuts->removeElement($cashOut)) {
  142.             // set the owning side to null (unless already changed)
  143.             if ($cashOut->getUser() === $this) {
  144.                 $cashOut->setUser(null);
  145.             }
  146.         }
  147.         return $this;
  148.     }
  149.     public function getVacationDays(): ?int
  150.     {
  151.         return $this->vacationDays;
  152.     }
  153.     public function setVacationDays(?int $vacationDays): self
  154.     {
  155.         $this->vacationDays $vacationDays;
  156.         return $this;
  157.     }
  158.     public function getUserAnualLeavs(): ArrayCollection
  159.     {
  160.         return $this->userAnualLeavs;
  161.     }
  162.     public function setUserAnualLeavs(ArrayCollection $userAnualLeavs): void
  163.     {
  164.         $this->userAnualLeavs $userAnualLeavs;
  165.     }
  166.     /**
  167.      * @return Collection<int, AnualLeave>
  168.      */
  169.     public function getUserAnualLeave(): Collection
  170.     {
  171.         return $this->cashOuts;
  172.     }
  173.     public function addAnualLeave(AnualLeave $anualLeave): self
  174.     {
  175.         if (!$this->cashOuts->contains($anualLeave)) {
  176.             $this->cashOuts[] = $anualLeave;
  177.             $anualLeave->setUser($this);
  178.         }
  179.         return $this;
  180.     }
  181.     public function removeAnualLeave(AnualLeave $anualLeave): self
  182.     {
  183.         if ($this->cashOuts->removeElement($anualLeave)) {
  184.             // set the owning side to null (unless already changed)
  185.             if ($anualLeave->getUser() === $this) {
  186.                 $anualLeave->setUser(null);
  187.             }
  188.         }
  189.         return $this;
  190.     }
  191. }