src/Entity/ServiceDelivery.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Serializer\Annotation\Groups;
  5. /**
  6. * ServiceDelivery
  7. *
  8. * @ORM\Table(name="service_delivery")
  9. * @ORM\Entity
  10. */
  11. class ServiceDelivery
  12. {
  13. /**
  14. * @var int
  15. *
  16. * @ORM\Column(name="id", type="integer", nullable=false)
  17. * @ORM\Id
  18. * @ORM\GeneratedValue(strategy="IDENTITY")
  19. */
  20. private $id;
  21. /**
  22. * @var string|null
  23. *
  24. * @ORM\Column(name="label", type="string", length=255, nullable=true, options={"default"="NULL"})
  25. * @Groups({"agenda-api"})
  26. */
  27. private $label;
  28. /**
  29. * @var float|null
  30. *
  31. * @ORM\Column(name="price", type="float", precision=10, scale=0, nullable=true, options={"default"="NULL"})
  32. */
  33. private $price;
  34. /**
  35. * @var float|null
  36. *
  37. * @ORM\Column(name="discount", type="float", precision=10, scale=0, nullable=true, options={"default"="NULL"})
  38. */
  39. private $discount;
  40. /**
  41. * @var int|null
  42. *
  43. * @ORM\Column(name="duration", type="integer", nullable=true, options={"default"=60})
  44. */
  45. private $duration = 60;
  46. /**
  47. * @var bool|null
  48. *
  49. * @ORM\Column(name="enabled", type="boolean", nullable=true, options={"default"="1"})
  50. */
  51. private $enabled = true;
  52. /**
  53. * @var bool|null
  54. *
  55. * @ORM\Column(name="is_coaching", type="boolean", nullable=true, options={"default"="0"})
  56. * @Groups({"agenda-api"})
  57. */
  58. private $isCoaching = false;
  59. /**
  60. * @var \Doctrine\Common\Collections\Collection
  61. *
  62. * @ORM\ManyToMany(targetEntity="ServiceDeliveryPlace", inversedBy="serviceDelivery")
  63. * @ORM\JoinTable(name="service_delivery_has_place",
  64. * joinColumns={
  65. * @ORM\JoinColumn(name="service_delivery_id", referencedColumnName="id")
  66. * },
  67. * inverseJoinColumns={
  68. * @ORM\JoinColumn(name="service_delivery_place_id", referencedColumnName="id")
  69. * }
  70. * )
  71. */
  72. private $serviceDeliveryPlace = array();
  73. /**
  74. * @var \Doctrine\Common\Collections\Collection
  75. *
  76. * @ORM\OneToMany(targetEntity="ServiceDeliveryHasPlace", mappedBy="serviceDelivery")
  77. */
  78. private $serviceDeliveryHasPlace;
  79. /**
  80. * @var Partner|null
  81. *
  82. * @ORM\ManyToOne(targetEntity="Partner", inversedBy="servicesDeliveries")
  83. * @ORM\JoinColumns({
  84. * @ORM\JoinColumn(name="partner_id", referencedColumnName="id")
  85. * })
  86. */
  87. private $partner;
  88. /**
  89. * @var ServiceDelivery|null
  90. *
  91. * @ORM\ManyToOne(targetEntity="ServiceDelivery")
  92. * @ORM\JoinColumns({
  93. * @ORM\JoinColumn(name="history_service_id", referencedColumnName="id")
  94. * })
  95. */
  96. private $historyService;
  97. /**
  98. * @var bool|null
  99. *
  100. * @ORM\Column(name="first_reservation_only", type="boolean", nullable=true, options={"default"="0"})
  101. */
  102. private $firstReservationOnly = false;
  103. /**
  104. * @var bool|null
  105. *
  106. * @ORM\Column(name="second_reservation_only", type="boolean", nullable=true, options={"default"="0"})
  107. */
  108. private $secondReservationOnly = false;
  109. /**
  110. * Constructor
  111. */
  112. public function __construct()
  113. {
  114. $this->serviceDeliveryPlace = new \Doctrine\Common\Collections\ArrayCollection();
  115. }
  116. /**
  117. * @return int
  118. */
  119. public function getId(): int
  120. {
  121. return $this->id;
  122. }
  123. /**
  124. * @param int $id
  125. */
  126. public function setId(int $id): void
  127. {
  128. $this->id = $id;
  129. }
  130. /**
  131. * @return string|null
  132. */
  133. public function getLabel(): ?string
  134. {
  135. return $this->label;
  136. }
  137. /**
  138. * @param string|null $label
  139. */
  140. public function setLabel(?string $label): void
  141. {
  142. $this->label = $label;
  143. }
  144. /**
  145. * @return float|null
  146. */
  147. public function getPrice(): ?float
  148. {
  149. return $this->price;
  150. }
  151. /**
  152. * @param float|null $price
  153. */
  154. public function setPrice(?float $price): void
  155. {
  156. $this->price = $price;
  157. }
  158. /**
  159. * @return float|null
  160. */
  161. public function getDiscount(): ?float
  162. {
  163. return $this->discount;
  164. }
  165. /**
  166. * @param float|null $discount
  167. */
  168. public function setDiscount(?float $discount): void
  169. {
  170. $this->discount = $discount;
  171. }
  172. /**
  173. * @return int|null
  174. */
  175. public function getDuration(): ?int
  176. {
  177. return $this->duration;
  178. }
  179. /**
  180. * @param int|null $duration
  181. */
  182. public function setDuration(?int $duration): void
  183. {
  184. $this->duration = $duration;
  185. }
  186. /**
  187. * @return bool|null
  188. */
  189. public function getEnabled(): ?bool
  190. {
  191. return $this->enabled;
  192. }
  193. /**
  194. * @param bool|null $enabled
  195. */
  196. public function setEnabled(?bool $enabled): void
  197. {
  198. $this->enabled = $enabled;
  199. }
  200. /**
  201. * @return bool|null
  202. */
  203. public function getIsCoaching(): ?bool
  204. {
  205. return $this->isCoaching;
  206. }
  207. /**
  208. * @param bool|null $isCoaching
  209. */
  210. public function setIsCoaching(?bool $isCoaching): void
  211. {
  212. $this->isCoaching = $isCoaching;
  213. }
  214. /**
  215. * @return \Doctrine\Common\Collections\Collection
  216. */
  217. public function getServiceDeliveryPlace()
  218. {
  219. return $this->serviceDeliveryPlace;
  220. }
  221. /**
  222. * @param \Doctrine\Common\Collections\Collection $serviceDeliveryPlace
  223. */
  224. public function setServiceDeliveryPlace($serviceDeliveryPlace): void
  225. {
  226. $this->serviceDeliveryPlace = $serviceDeliveryPlace;
  227. }
  228. /**
  229. * @return \Doctrine\Common\Collections\Collection
  230. */
  231. public function getServiceDeliveryHasPlace()
  232. {
  233. return $this->serviceDeliveryHasPlace;
  234. }
  235. /**
  236. * @param \Doctrine\Common\Collections\Collection $serviceDeliveryHasPlace
  237. */
  238. public function setServiceDeliveryHasPlace($serviceDeliveryHasPlace): void
  239. {
  240. $this->serviceDeliveryHasPlace = $serviceDeliveryHasPlace;
  241. }
  242. /**
  243. * @return Partner|null
  244. */
  245. public function getPartner(): ?Partner
  246. {
  247. return $this->partner;
  248. }
  249. /**
  250. * @param Partner|null $partner
  251. */
  252. public function setPartner(?Partner $partner): void
  253. {
  254. $this->partner = $partner;
  255. }
  256. /**
  257. * @return ServiceDelivery|null
  258. */
  259. public function getHistoryService(): ?ServiceDelivery
  260. {
  261. return $this->historyService;
  262. }
  263. /**
  264. * @param ServiceDelivery|null $historyService
  265. */
  266. public function setHistoryService(?ServiceDelivery $historyService): void
  267. {
  268. $this->historyService = $historyService;
  269. }
  270. /**
  271. * @return bool|null
  272. */
  273. public function getFirstReservationOnly(): ?bool
  274. {
  275. return $this->firstReservationOnly;
  276. }
  277. /**
  278. * @param bool|null $firstReservationOnly
  279. */
  280. public function setFirstReservationOnly(?bool $firstReservationOnly): void
  281. {
  282. $this->firstReservationOnly = $firstReservationOnly;
  283. }
  284. /**
  285. * @return bool|null
  286. */
  287. public function getSecondReservationOnly(): ?bool
  288. {
  289. return $this->secondReservationOnly;
  290. }
  291. /**
  292. * @param bool|null $secondReservationOnly
  293. */
  294. public function setSecondReservationOnly(?bool $secondReservationOnly): void
  295. {
  296. $this->secondReservationOnly = $secondReservationOnly;
  297. }
  298. public function getRealPrice(): ?float
  299. {
  300. if (!$this->getDiscount()) {
  301. return $this->getPrice();
  302. }
  303. return $this->getPrice()*(1-($this->getDiscount()/100));
  304. }
  305. }