<?php
namespace App\Entity\Services;
use Symfony\Component\Validator\Constraints AS Constraints;
use Symfony\Component\Validator\Constraints AS Assert;
use Doctrine\ORM\Mapping AS ORM;
use Ramsey\Uuid\Uuid;
/**
* @ORM\Entity(repositoryClass="App\Repository\Services\ServiceRepository")
* @ORM\Table(name="services_service")
* @ORM\HasLifecycleCallbacks()
*/
class Service
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="uuid")
* @Assert\Uuid
*/
protected $uuid;
/**
* @var \DateTime
*
* @ORM\Column(type="datetime", nullable=false)
*/
private $created;
/**
* @ORM\Column(type="string", length=60, nullable=false)
*/
private $name;
/**
* @ORM\Column(type="string", length=60, nullable=false)
*/
private $pricingType;
/**
* @ORM\Column(type="boolean")
*/
private $isLocked;
/**
* @ORM\Column(type="boolean")
*/
private $isPinned;
/**
* @ORM\Column(type="boolean")
*/
private $enableQuickAdd;
/**
* @ORM\Column(type="boolean")
*/
private $displayOnDashboard;
/**
* @ORM\Column(type="boolean")
*/
private $allowMultiple;
/**
* @ORM\Column(type="boolean")
*/
private $dateRequired;
public function __construct($data = array())
{
// UUID
if(!$this->getUuid())
{
$uuid = Uuid::uuid1();
$this->setUuid($uuid->toString());
}
// Set some defaults
$this->setCreated(new \DateTime());
$this->setIsPinned(false);
$this->setDisplayOnDashboard(false);
$this->setAllowMultiple(false);
$this->setIsLocked(false);
$this->setEnableQuickAdd(false);
$this->setDateRequired(false);
// Pre-set data
foreach($data AS $k => $v)
{
// Valid?
$methodName = 'set' . ucfirst($k);
if(method_exists($this, $methodName))
$this->$methodName($v);
}
}
public function __toString()
{
return (string)$this->getName();
}
public function getId()
{
return $this->id;
}
public function setUuid($uuid)
{
$this->uuid = $uuid;
return $this;
}
public function getUuid()
{
return $this->uuid;
}
public function getCreated()
{
return $this->created;
}
public function setCreated(\DateTime $created)
{
$this->created = $created;
}
public function getName()
{
return $this->name;
}
public function setName(string $name)
{
$this->name = $name;
}
public function getPricingType()
{
return $this->pricingType;
}
public function setPricingType(string $pricingType)
{
$this->pricingType = $pricingType;
}
public function getIsPinned()
{
return $this->isPinned;
}
public function setIsPinned($isPinned)
{
$this->isPinned = $isPinned;
}
public function getIsLocked()
{
return $this->isLocked;
}
public function setIsLocked($isLocked)
{
$this->isLocked = $isLocked;
}
public function getEnableQuickAdd()
{
return $this->enableQuickAdd;
}
public function setEnableQuickAdd($enableQuickAdd)
{
$this->enableQuickAdd = $enableQuickAdd;
}
public function getDisplayOnDashboard()
{
return $this->displayOnDashboard;
}
public function setDisplayOnDashboard($displayOnDashboard)
{
$this->displayOnDashboard = $displayOnDashboard;
}
public function getAllowMultiple()
{
return $this->allowMultiple;
}
public function setAllowMultiple($allowMultiple)
{
$this->allowMultiple = $allowMultiple;
}
public function getDateRequired()
{
return $this->dateRequired;
}
public function setDateRequired($dateRequired)
{
$this->dateRequired = $dateRequired;
}
}