144 lines
2.6 KiB
PHP
144 lines
2.6 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="rider_schedule")
|
|
*/
|
|
class RiderSchedule
|
|
{
|
|
// unique id
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\Column(type="integer")
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
*/
|
|
protected $id;
|
|
|
|
// rider the schedule is for
|
|
/**
|
|
* @ORM\ManyToOne(targetEntity="Rider", inversedBy="schedules")
|
|
* @ORM\JoinColumn(name="rider_id", referencedColumnName="id")
|
|
*/
|
|
protected $rider;
|
|
|
|
// start time
|
|
/**
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
protected $day_of_week;
|
|
|
|
// start time
|
|
/**
|
|
* @ORM\Column(type="time")
|
|
*/
|
|
protected $time_start;
|
|
|
|
// end time
|
|
/**
|
|
* @ORM\Column(type="time")
|
|
*/
|
|
protected $time_end;
|
|
|
|
// break start time
|
|
/**
|
|
* @ORM\Column(type="time")
|
|
*/
|
|
protected $break_start;
|
|
|
|
// break end time
|
|
/**
|
|
* @ORM\Column(type="time")
|
|
*/
|
|
protected $break_end;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->time_start = new DateTime();
|
|
$this->time_end = new DateTime();
|
|
$this->break_start = new DateTime();
|
|
$this->break_end = new DateTime();
|
|
}
|
|
|
|
public function getID()
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function setRider(Rider $rider)
|
|
{
|
|
$this->rider = $rider;
|
|
return $this;
|
|
}
|
|
|
|
public function getRider()
|
|
{
|
|
return $this->rider;
|
|
}
|
|
|
|
public function setDayOfWeek($day)
|
|
{
|
|
$this->day_of_week = $day;
|
|
return $this;
|
|
}
|
|
|
|
public function getDayOfWeek()
|
|
{
|
|
return $this->day_of_week;
|
|
}
|
|
|
|
public function setTimeStart($time)
|
|
{
|
|
$this->time_start = $this->parseTime($time);
|
|
return $this;
|
|
}
|
|
|
|
public function getTimeStart()
|
|
{
|
|
return $this->time_start;
|
|
}
|
|
|
|
public function setTimeEnd($time)
|
|
{
|
|
$this->time_end = $this->parseTime($time);
|
|
return $this;
|
|
}
|
|
|
|
public function getTimeEnd()
|
|
{
|
|
return $this->time_end;
|
|
}
|
|
|
|
public function setBreakStart($time)
|
|
{
|
|
$this->break_start = $this->parseTime($time);
|
|
return $this;
|
|
}
|
|
|
|
public function getBreakStart()
|
|
{
|
|
return $this->break_start;
|
|
}
|
|
|
|
public function setBreakEnd($time)
|
|
{
|
|
$this->break_end = $this->parseTime($time);
|
|
return $this;
|
|
}
|
|
|
|
public function getBreakEnd()
|
|
{
|
|
return $this->break_end;
|
|
}
|
|
|
|
protected function parseTime($string, $format = 'g:i A')
|
|
{
|
|
return DateTime::createFromFormat($format, $string) ?? null;
|
|
}
|
|
}
|