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.     /**
  51.      * @ORM\Column(type="decimal", precision=11, scale=2, nullable=true)
  52.      */
  53.     private ?string $monthlySalary = null;
  54.     /**
  55.      * @ORM\Column(type="decimal", precision=11, scale=2, nullable=true)
  56.      */
  57.     private ?string $hourlyWage = null;
  58.     public function __construct()
  59.     {
  60.         $this->assignedTasks = new ArrayCollection();
  61.         $this->taskLogs = new ArrayCollection();
  62.         $this->cashOuts = new ArrayCollection();
  63.         $this->userAnualLeavs = new ArrayCollection();
  64.     }
  65.     public function getName(): ?string
  66.     {
  67.         return $this->name;
  68.     }
  69.     public function setName(?string $name): void
  70.     {
  71.         $this->name = $name;
  72.     }
  73.     /**
  74.      * @return Collection<int, Task>
  75.      */
  76.     public function getAssignedTasks(): Collection
  77.     {
  78.         return $this->assignedTasks;
  79.     }
  80.     public function addAssignedTask(Task $assignedTask): self
  81.     {
  82.         if (!$this->assignedTasks->contains($assignedTask)) {
  83.             $this->assignedTasks[] = $assignedTask;
  84.             $assignedTask->setAssignedUser($this);
  85.         }
  86.         return $this;
  87.     }
  88.     public function removeAssignedTask(Task $assignedTask): self
  89.     {
  90.         if ($this->assignedTasks->removeElement($assignedTask)) {
  91.             // set the owning side to null (unless already changed)
  92.             if ($assignedTask->getAssignedUser() === $this) {
  93.                 $assignedTask->setAssignedUser(null);
  94.             }
  95.         }
  96.         return $this;
  97.     }
  98.     /**
  99.      * @return Collection<int, TaskLog>
  100.      */
  101.     public function getTaskLogs(): Collection
  102.     {
  103.         return $this->taskLogs;
  104.     }
  105.     public function addTaskLog(TaskLog $taskLog): self
  106.     {
  107.         if (!$this->taskLogs->contains($taskLog)) {
  108.             $this->taskLogs[] = $taskLog;
  109.             $taskLog->setUser($this);
  110.         }
  111.         return $this;
  112.     }
  113.     public function removeTaskLog(TaskLog $taskLog): self
  114.     {
  115.         if ($this->taskLogs->removeElement($taskLog)) {
  116.             // set the owning side to null (unless already changed)
  117.             if ($taskLog->getUser() === $this) {
  118.                 $taskLog->setUser(null);
  119.             }
  120.         }
  121.         return $this;
  122.     }
  123.     public function getPhone(): ?string
  124.     {
  125.         return $this->phone;
  126.     }
  127.     public function setPhone(?string $phone): self
  128.     {
  129.         $this->phone = $phone;
  130.         return $this;
  131.     }
  132.     /**
  133.      * @return Collection<int, CashOut>
  134.      */
  135.     public function getCashOuts(): Collection
  136.     {
  137.         return $this->cashOuts;
  138.     }
  139.     public function addCashOut(CashOut $cashOut): self
  140.     {
  141.         if (!$this->cashOuts->contains($cashOut)) {
  142.             $this->cashOuts[] = $cashOut;
  143.             $cashOut->setUser($this);
  144.         }
  145.         return $this;
  146.     }
  147.     public function removeCashOut(CashOut $cashOut): self
  148.     {
  149.         if ($this->cashOuts->removeElement($cashOut)) {
  150.             // set the owning side to null (unless already changed)
  151.             if ($cashOut->getUser() === $this) {
  152.                 $cashOut->setUser(null);
  153.             }
  154.         }
  155.         return $this;
  156.     }
  157.     public function getVacationDays(): ?int
  158.     {
  159.         return $this->vacationDays;
  160.     }
  161.     public function setVacationDays(?int $vacationDays): self
  162.     {
  163.         $this->vacationDays = $vacationDays;
  164.         return $this;
  165.     }
  166.     public function getMonthlySalary(): ?string
  167.     {
  168.         return $this->monthlySalary;
  169.     }
  170.     public function setMonthlySalary($monthlySalary): self
  171.     {
  172.         $this->monthlySalary = ($monthlySalary === null || $monthlySalary === '')
  173.             ? null
  174.             : (string) $monthlySalary;
  175.         return $this;
  176.     }
  177.     public function getHourlyWage(): ?string
  178.     {
  179.         return $this->hourlyWage;
  180.     }
  181.     public function setHourlyWage($hourlyWage): self
  182.     {
  183.         $this->hourlyWage = ($hourlyWage === null || $hourlyWage === '')
  184.             ? null
  185.             : (string) $hourlyWage;
  186.         return $this;
  187.     }
  188.     public function getUserAnualLeavs(): ArrayCollection
  189.     {
  190.         return $this->userAnualLeavs;
  191.     }
  192.     public function setUserAnualLeavs(ArrayCollection $userAnualLeavs): void
  193.     {
  194.         $this->userAnualLeavs = $userAnualLeavs;
  195.     }
  196.     /**
  197.      * @return Collection<int, AnualLeave>
  198.      */
  199.     public function getUserAnualLeave(): Collection
  200.     {
  201.         return $this->cashOuts;
  202.     }
  203.     public function addAnualLeave(AnualLeave $anualLeave): self
  204.     {
  205.         if (!$this->cashOuts->contains($anualLeave)) {
  206.             $this->cashOuts[] = $anualLeave;
  207.             $anualLeave->setUser($this);
  208.         }
  209.         return $this;
  210.     }
  211.     public function removeAnualLeave(AnualLeave $anualLeave): self
  212.     {
  213.         if ($this->cashOuts->removeElement($anualLeave)) {
  214.             // set the owning side to null (unless already changed)
  215.             if ($anualLeave->getUser() === $this) {
  216.                 $anualLeave->setUser(null);
  217.             }
  218.         }
  219.         return $this;
  220.     }
  221. }