src/Entity/DayOff.php line 16
- <?php
- namespace App\Entity;
- use Doctrine\Common\Collections\ArrayCollection;
- use Doctrine\Common\Collections\Collection;
- use Doctrine\DBAL\Types\Types;
- use Doctrine\ORM\Mapping as ORM;
- /**
- * DayOff
- *
- * @ORM\Table("day_off")
- * @ORM\Entity()
- */
- class DayOff
- {
- /**
- * @var integer
- *
- * @ORM\Column(name="id", type="integer")
- * @ORM\Id
- * @ORM\GeneratedValue(strategy="AUTO")
- */
- private $id;
- /**
- * @var \DateTime
- *
- * @ORM\Column(name="dayoff", type="date", nullable=false)
- */
- private $date;
- /**
- * @ORM\OneToMany(targetEntity="HorarioReducido", mappedBy="dayoff", cascade={"persist", "remove"}, orphanRemoval=true)
- */
- private $horarioReducidos;
- /**
- * @ORM\ManyToMany(targetEntity="Oficina", inversedBy="dayoffs")
- * @ORM\JoinTable(name="oficina", referencedColumnName="id")
- */
- // private $oficinas;
- /**
- * @ORM\ManyToOne(targetEntity="Oficina", inversedBy="dayoffs"))
- * @ORM\JoinColumn(name="oficina", referencedColumnName="id")
- */
- private $oficina;
- public function __toString()
- {
- // if ($this->getDate())
- return $this->getDate()->format('Y-m-d');
- // return "na";
- }
- public function __construct()
- {
- $this->date = new \DateTime("now");
- $this->horarioReducidos = new ArrayCollection();
- // $this->oficinas = new ArrayCollection();
- }
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set date
- *
- * @param \DateTime $date
- * @return DayOff
- */
- public function setDate(\DateTime $date)
- {
- $this->date = $date;
- return $this;
- }
- /**
- * Get date
- *
- * @return \DateTime
- */
- public function getDate()
- {
- return $this->date;
- }
- /**
- * add horarioReducio
- *
- * @param horarioReducido $horarioReducio
- * @return DayOff
- */
- public function addHorarioReducido(HorarioReducido $horarioReducido): self
- {
- if (!$this->horarioReducidos->contains($horarioReducido)) {
- $this->horarioReducidos->add($horarioReducido);
- $horarioReducido->setDayoff($this);
- }
- return $this;
- }
- /**
- * Get horarioReducios
- *
- * @return ArrayCollection
- */
- public function getHorarioReducidos()
- {
- return $this->horarioReducidos;
- }
- /**
- * @param mixed $horarioReducios
- */
- public function setHorarioReducidos($horarioReducidos)
- {
- $this->horarioReducidos = $horarioReducidos;
- }
- public function removeHorarioReducido($horarioReducido){
- $this->horarioReducidos->removeElement($horarioReducido);
- return $this;
- }
- public function getDateString()
- {
- $this->getDate()->format('d-m-Y');
- }
- /**
- * Set oficina
- *
- * @param Oficina $oficina
- * @return Oficina
- */
- public function setOficina(Oficina $oficina)
- {
- $this->oficina = $oficina;
- return $this;
- }
- /**
- * Get oficina
- *
- * @return boolean
- */
- public function getOficina()
- {
- return $this->oficina;
- }
- // public function getOficinas(): Collection
- // {
- // return $this->oficinas;
- // }
- //
- // public function addOficina(Oficina $oficina): self
- // {
- // if (!$this->oficinas->contains($oficina)) {
- // $this->oficinas[] = $oficina;
- // }
- //
- // return $this;
- // }
- //
- // public function removeOficina(Oficina $oficina): self
- // {
- // $this->oficinas->removeElement($oficina);
- //
- // return $this;
- // }
- }