Guest User

Untitled

a guest
Apr 21st, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.38 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7.  
  8. /**
  9. * @ORM\Entity(repositoryClass="App\Repository\BookRepository")
  10. * @ORM\Table(name="books")
  11. * @ORM\HasLifecycleCallbacks
  12. */
  13. class Book
  14. {
  15. /**
  16. * @ORM\Id()
  17. * @ORM\GeneratedValue()
  18. * @ORM\Column(type="integer", options={"unsigned":true})
  19. */
  20. private $id;
  21.  
  22. /**
  23. * @ORM\Column(type="string", length=255)
  24. */
  25. private $slug;
  26.  
  27. /**
  28. * @ORM\Column(type="string", length=255, nullable=true)
  29. *
  30. * @Assert\NotBlank(message="Please, upload the product brochure as a Image file.")
  31. * @Assert\File(mimeTypes={ "image/jpeg" })
  32. */
  33. private $cover;
  34.  
  35. /**
  36. * @ORM\Column(type="string", length=255)
  37. */
  38. private $name;
  39.  
  40. /**
  41. * @ORM\Column(type="text")
  42. */
  43. private $description;
  44.  
  45. /**
  46. * @ORM\Column(type="text")
  47. */
  48. private $plot;
  49.  
  50. /**
  51. * @ORM\Column(type="date")
  52. */
  53. private $published_at;
  54.  
  55. /**
  56. * @ORM\Column(type="datetime")
  57. */
  58. private $created_at;
  59.  
  60. /**
  61. * @ORM\Column(type="datetime", nullable=true)
  62. */
  63. private $updated_at;
  64.  
  65.  
  66. public function getId()
  67. {
  68. return $this->id;
  69. }
  70.  
  71. public function getSlug(): ?string
  72. {
  73. return $this->slug;
  74. }
  75.  
  76. public function setSlug(string $slug): self
  77. {
  78. $this->slug = $slug;
  79.  
  80. return $this;
  81. }
  82.  
  83. public function getCover()
  84. {
  85. return $this->cover;
  86. }
  87.  
  88. public function setCover($cover): self
  89. {
  90. $this->cover = $cover;
  91.  
  92. return $this;
  93. }
  94.  
  95. public function getName(): ?string
  96. {
  97. return $this->name;
  98. }
  99.  
  100. public function setName(string $name): self
  101. {
  102. $this->name = $name;
  103.  
  104. return $this;
  105. }
  106.  
  107. public function getDescription(): ?string
  108. {
  109. return $this->description;
  110. }
  111.  
  112. public function setDescription(string $description): self
  113. {
  114. $this->description = $description;
  115.  
  116. return $this;
  117. }
  118.  
  119. public function getPlot(): ?string
  120. {
  121. return $this->plot;
  122. }
  123.  
  124. public function setPlot(string $plot): self
  125. {
  126. $this->plot = $plot;
  127.  
  128. return $this;
  129. }
  130.  
  131. public function getPublishedAt(): ?\DateTimeInterface
  132. {
  133. return $this->published_at;
  134. }
  135.  
  136. public function setPublishedAt(\DateTimeInterface $published_at): self
  137. {
  138. $this->published_at = $published_at;
  139.  
  140. return $this;
  141. }
  142.  
  143. public function getCreatedAt(): ?\DateTimeInterface
  144. {
  145. return $this->created_at;
  146. }
  147.  
  148. public function setCreatedAt(\DateTimeInterface $created_at): self
  149. {
  150. $this->created_at = $created_at;
  151.  
  152. return $this;
  153. }
  154.  
  155. public function getUpdatedAt(): ?\DateTimeInterface
  156. {
  157. return $this->updated_at;
  158. }
  159.  
  160. public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  161. {
  162. $this->updated_at = $updated_at;
  163.  
  164. return $this;
  165. }
  166.  
  167. /**
  168. *
  169. * @ORM\PrePersist
  170. * @ORM\PreUpdate
  171. */
  172. public function updatedTimestamps()
  173. {
  174. $this->setUpdatedAt(new \DateTime('now'));
  175. $this->setCreatedAt($this->getCreatedAt() ?? new \DateTime('now'));
  176. }
  177. }
Add Comment
Please, Sign In to add comment