Advertisement
Guest User

Untitled

a guest
Apr 20th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 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=32)
  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=32)
  37. */
  38. private $name;
  39.  
  40. /**
  41. * @ORM\Column(type="text")
  42. */
  43. private $description;
  44.  
  45. /**
  46. * @ORM\Column(type="date")
  47. */
  48. private $released_at;
  49.  
  50. /**
  51. * @ORM\Column(type="datetime")
  52. */
  53. private $created_at;
  54.  
  55. /**
  56. * @ORM\Column(type="datetime", nullable=true)
  57. */
  58. private $updated_at;
  59.  
  60. public function getId()
  61. {
  62. return $this->id;
  63. }
  64.  
  65. public function getSlug(): ?string
  66. {
  67. return $this->slug;
  68. }
  69.  
  70. public function setSlug(string $slug): self
  71. {
  72. $this->slug = $slug;
  73.  
  74. return $this;
  75. }
  76.  
  77. public function getCover()
  78. {
  79. return $this->cover;
  80. }
  81.  
  82. public function setCover($cover): self
  83. {
  84. $this->cover = $cover;
  85.  
  86. return $this;
  87. }
  88.  
  89. public function getName(): ?string
  90. {
  91. return $this->name;
  92. }
  93.  
  94. public function setName(string $name): self
  95. {
  96. $this->name = $name;
  97.  
  98. return $this;
  99. }
  100.  
  101. public function getDescription(): ?string
  102. {
  103. return $this->description;
  104. }
  105.  
  106. public function setDescription(string $description): self
  107. {
  108. $this->description = $description;
  109.  
  110. return $this;
  111. }
  112.  
  113. public function getReleasedAt(): ?\DateTimeInterface
  114. {
  115. return $this->released_at;
  116. }
  117.  
  118. public function setReleasedAt(\DateTimeInterface $released_at): self
  119. {
  120. $this->released_at = $released_at;
  121.  
  122. return $this;
  123. }
  124.  
  125. public function getCreatedAt(): ?\DateTimeInterface
  126. {
  127. return $this->created_at;
  128. }
  129.  
  130. public function setCreatedAt(\DateTimeInterface $created_at): self
  131. {
  132. $this->created_at = $created_at;
  133.  
  134. return $this;
  135. }
  136.  
  137. public function getUpdatedAt(): ?\DateTimeInterface
  138. {
  139. return $this->updated_at;
  140. }
  141.  
  142. public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  143. {
  144. $this->updated_at = $updated_at;
  145.  
  146. return $this;
  147. }
  148.  
  149. /**
  150. *
  151. * @ORM\PrePersist
  152. * @ORM\PreUpdate
  153. */
  154. public function updatedTimestamps()
  155. {
  156. $this->setUpdatedAt(new \DateTime('now'));
  157. $this->setCreatedAt($this->getCreatedAt() ?? new \DateTime('now'));
  158. }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement