src/Entity/DayOff.php line 16

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * DayOff
  9.  *
  10.  * @ORM\Table("day_off")
  11.  * @ORM\Entity()
  12.  */
  13. class DayOff
  14. {
  15.     /**
  16.      * @var integer
  17.      *
  18.      * @ORM\Column(name="id", type="integer")
  19.      * @ORM\Id
  20.      * @ORM\GeneratedValue(strategy="AUTO")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @var \DateTime
  25.      *
  26.      * @ORM\Column(name="dayoff", type="date", nullable=false)
  27.      */
  28.     private $date;
  29.     /**
  30.      * @ORM\OneToMany(targetEntity="HorarioReducido", mappedBy="dayoff", cascade={"persist", "remove"}, orphanRemoval=true)
  31.      */
  32.     private $horarioReducidos;
  33.     
  34.     /**
  35.      * @ORM\ManyToMany(targetEntity="Oficina", inversedBy="dayoffs")
  36.      * @ORM\JoinTable(name="oficina", referencedColumnName="id")
  37.      */
  38. //     private $oficinas;
  39.     
  40.     /**    
  41.     * @ORM\ManyToOne(targetEntity="Oficina", inversedBy="dayoffs"))
  42.     * @ORM\JoinColumn(name="oficina", referencedColumnName="id")
  43.     */
  44.     private $oficina;
  45.     
  46.     
  47.     public function __toString()
  48.     {
  49. //         if ($this->getDate())
  50.             return $this->getDate()->format('Y-m-d');
  51.         
  52. //         return "na";
  53.     }
  54.     public function __construct()
  55.     {
  56.         $this->date = new \DateTime("now");
  57.         $this->horarioReducidos = new ArrayCollection();
  58. //         $this->oficinas = new ArrayCollection();
  59.     }
  60.     
  61.     /**
  62.      * Get id
  63.      *
  64.      * @return integer 
  65.      */
  66.     public function getId()
  67.     {
  68.         return $this->id;
  69.     }
  70.     /**
  71.      * Set date
  72.      *
  73.      * @param \DateTime $date
  74.      * @return DayOff
  75.      */
  76.     public function setDate(\DateTime $date)
  77.     {
  78.         $this->date $date;
  79.         return $this;
  80.     }
  81.     /**
  82.      * Get date
  83.      *
  84.      * @return \DateTime
  85.      */
  86.     public function getDate()
  87.     {
  88.         return $this->date;
  89.     }
  90.     /**
  91.      * add horarioReducio
  92.      *
  93.      * @param horarioReducido $horarioReducio
  94.      * @return DayOff
  95.      */
  96.     public function addHorarioReducido(HorarioReducido $horarioReducido): self
  97.     {
  98.         if (!$this->horarioReducidos->contains($horarioReducido)) {
  99.             $this->horarioReducidos->add($horarioReducido);
  100.             $horarioReducido->setDayoff($this);
  101.         }
  102.         return $this;
  103.     }
  104.     /**
  105.      * Get horarioReducios
  106.      *
  107.      * @return ArrayCollection
  108.      */
  109.     public function getHorarioReducidos()
  110.     {
  111.         return $this->horarioReducidos;
  112.     }
  113.     /**
  114.      * @param mixed $horarioReducios
  115.      */
  116.     public function setHorarioReducidos($horarioReducidos)
  117.     {
  118.         $this->horarioReducidos $horarioReducidos;
  119.     }
  120.     public function removeHorarioReducido($horarioReducido){
  121.         $this->horarioReducidos->removeElement($horarioReducido);
  122.         return $this;
  123.     }
  124.     
  125.     public function getDateString()
  126.     {
  127.         $this->getDate()->format('d-m-Y');
  128.     }
  129.     /**
  130.      * Set oficina
  131.      *
  132.      * @param Oficina $oficina
  133.      * @return Oficina
  134.      */
  135.     public function setOficina(Oficina $oficina)
  136.     {
  137.         
  138.         $this->oficina $oficina;
  139.         return $this;
  140.     }
  141.     /**
  142.      * Get oficina
  143.      *
  144.      * @return boolean 
  145.      */
  146.     public function getOficina()
  147.     {
  148.         return $this->oficina;
  149.     }
  150.     
  151.     
  152. //     public function getOficinas(): Collection
  153. //     {
  154. //         return $this->oficinas;
  155. //     }
  156. // 
  157. //     public function addOficina(Oficina $oficina): self
  158. //     {
  159. //         if (!$this->oficinas->contains($oficina)) {
  160. //             $this->oficinas[] = $oficina;
  161. //         }
  162. // 
  163. //         return $this;
  164. //     }
  165. // 
  166. //     public function removeOficina(Oficina $oficina): self
  167. //     {
  168. //         $this->oficinas->removeElement($oficina);
  169. // 
  170. //         return $this;
  171. //     }
  172.     
  173.     
  174. }