src/Entity/Services/Service.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Services;
  3. use Symfony\Component\Validator\Constraints AS Constraints;
  4. use Symfony\Component\Validator\Constraints AS Assert;
  5. use Doctrine\ORM\Mapping AS ORM;
  6. use Ramsey\Uuid\Uuid;
  7. /**
  8. * @ORM\Entity(repositoryClass="App\Repository\Services\ServiceRepository")
  9. * @ORM\Table(name="services_service")
  10. * @ORM\HasLifecycleCallbacks()
  11. */
  12. class Service
  13. {
  14. /**
  15. * @ORM\Id
  16. * @ORM\GeneratedValue(strategy="AUTO")
  17. * @ORM\Column(type="integer")
  18. */
  19. private $id;
  20. /**
  21. * @ORM\Column(type="uuid")
  22. * @Assert\Uuid
  23. */
  24. protected $uuid;
  25. /**
  26. * @var \DateTime
  27. *
  28. * @ORM\Column(type="datetime", nullable=false)
  29. */
  30. private $created;
  31. /**
  32. * @ORM\Column(type="string", length=60, nullable=false)
  33. */
  34. private $name;
  35. /**
  36. * @ORM\Column(type="string", length=60, nullable=false)
  37. */
  38. private $pricingType;
  39. /**
  40. * @ORM\Column(type="boolean")
  41. */
  42. private $isLocked;
  43. /**
  44. * @ORM\Column(type="boolean")
  45. */
  46. private $isPinned;
  47. /**
  48. * @ORM\Column(type="boolean")
  49. */
  50. private $enableQuickAdd;
  51. /**
  52. * @ORM\Column(type="boolean")
  53. */
  54. private $displayOnDashboard;
  55. /**
  56. * @ORM\Column(type="boolean")
  57. */
  58. private $allowMultiple;
  59. /**
  60. * @ORM\Column(type="boolean")
  61. */
  62. private $dateRequired;
  63. public function __construct($data = array())
  64. {
  65. // UUID
  66. if(!$this->getUuid())
  67. {
  68. $uuid = Uuid::uuid1();
  69. $this->setUuid($uuid->toString());
  70. }
  71. // Set some defaults
  72. $this->setCreated(new \DateTime());
  73. $this->setIsPinned(false);
  74. $this->setDisplayOnDashboard(false);
  75. $this->setAllowMultiple(false);
  76. $this->setIsLocked(false);
  77. $this->setEnableQuickAdd(false);
  78. $this->setDateRequired(false);
  79. // Pre-set data
  80. foreach($data AS $k => $v)
  81. {
  82. // Valid?
  83. $methodName = 'set' . ucfirst($k);
  84. if(method_exists($this, $methodName))
  85. $this->$methodName($v);
  86. }
  87. }
  88. public function __toString()
  89. {
  90. return (string)$this->getName();
  91. }
  92. public function getId()
  93. {
  94. return $this->id;
  95. }
  96. public function setUuid($uuid)
  97. {
  98. $this->uuid = $uuid;
  99. return $this;
  100. }
  101. public function getUuid()
  102. {
  103. return $this->uuid;
  104. }
  105. public function getCreated()
  106. {
  107. return $this->created;
  108. }
  109. public function setCreated(\DateTime $created)
  110. {
  111. $this->created = $created;
  112. }
  113. public function getName()
  114. {
  115. return $this->name;
  116. }
  117. public function setName(string $name)
  118. {
  119. $this->name = $name;
  120. }
  121. public function getPricingType()
  122. {
  123. return $this->pricingType;
  124. }
  125. public function setPricingType(string $pricingType)
  126. {
  127. $this->pricingType = $pricingType;
  128. }
  129. public function getIsPinned()
  130. {
  131. return $this->isPinned;
  132. }
  133. public function setIsPinned($isPinned)
  134. {
  135. $this->isPinned = $isPinned;
  136. }
  137. public function getIsLocked()
  138. {
  139. return $this->isLocked;
  140. }
  141. public function setIsLocked($isLocked)
  142. {
  143. $this->isLocked = $isLocked;
  144. }
  145. public function getEnableQuickAdd()
  146. {
  147. return $this->enableQuickAdd;
  148. }
  149. public function setEnableQuickAdd($enableQuickAdd)
  150. {
  151. $this->enableQuickAdd = $enableQuickAdd;
  152. }
  153. public function getDisplayOnDashboard()
  154. {
  155. return $this->displayOnDashboard;
  156. }
  157. public function setDisplayOnDashboard($displayOnDashboard)
  158. {
  159. $this->displayOnDashboard = $displayOnDashboard;
  160. }
  161. public function getAllowMultiple()
  162. {
  163. return $this->allowMultiple;
  164. }
  165. public function setAllowMultiple($allowMultiple)
  166. {
  167. $this->allowMultiple = $allowMultiple;
  168. }
  169. public function getDateRequired()
  170. {
  171. return $this->dateRequired;
  172. }
  173. public function setDateRequired($dateRequired)
  174. {
  175. $this->dateRequired = $dateRequired;
  176. }
  177. }