121 lines
2.2 KiB
PHP
121 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Validator\Constraints as Assert;
|
|
|
|
use DateTime;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="shift_schedule")
|
|
*/
|
|
class ShiftSchedule
|
|
{
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// shift name
|
|
/**
|
|
* @ORM\Column(type="string", length=50, nullable=true)
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $name;
|
|
|
|
// start time
|
|
/**
|
|
* @ORM\Column(type="time")
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $start_time;
|
|
|
|
// end time
|
|
/**
|
|
* @ORM\Column(type="time")
|
|
* @Assert\NotBlank()
|
|
*/
|
|
protected $end_time;
|
|
|
|
// hour shifts
|
|
/**
|
|
* @ORM\Column(type="json")
|
|
*/
|
|
protected $hour_shifts;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->start_time = new DateTime();
|
|
$this->end_time = new DateTime();
|
|
$this->hour_shifts = [];
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName()
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName($name)
|
|
{
|
|
$this->name = $name;
|
|
return $this;
|
|
}
|
|
|
|
public function getStartTime()
|
|
{
|
|
return $this->start_time;
|
|
}
|
|
|
|
public function setStartTime(DateTime $start_time)
|
|
{
|
|
$this->start_time = $start_time;
|
|
return $this;
|
|
}
|
|
|
|
public function getEndTime()
|
|
{
|
|
return $this->end_time;
|
|
}
|
|
|
|
public function setEndTime(DateTime $end_time)
|
|
{
|
|
$this->end_time = $end_time;
|
|
return $this;
|
|
}
|
|
|
|
public function addHourShift($id, $value)
|
|
{
|
|
$this->hour_shifts[$id] = $value;
|
|
return $this;
|
|
}
|
|
|
|
public function getHourShiftsById($id)
|
|
{
|
|
// return null if we don't have it
|
|
if (!isset($this->hour_shifts[$id]))
|
|
return null;
|
|
|
|
return $this->hour_shifts[$id];
|
|
}
|
|
|
|
public function getHourShifts()
|
|
{
|
|
return $this->hour_shifts;
|
|
}
|
|
|
|
public function setHourShifts(array $hour_shifts)
|
|
{
|
|
$this->hour_shifts = $hour_shifts;
|
|
return $this;
|
|
}
|
|
}
|