Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | None | 0 0
  1. <?php
  2.  
  3. namespace AppBundle\Entity;
  4.  
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Symfony\Component\Security\Core\User\UserInterface;
  8. use Symfony\Component\Validator\Constraints\DateTime;
  9.  
  10. /**
  11. * @ORM\Entity
  12. * @ORM\Table(name="owners")
  13. * @ORM\HasLifecycleCallbacks
  14. */
  15. class Owner implements UserInterface, \Serializable
  16. {
  17. /**
  18. * @ORM\Column(type="integer")
  19. * @ORM\Id
  20. * @ORM\GeneratedValue(strategy="AUTO")
  21. */
  22. private $id;
  23.  
  24. /**
  25. * @ORM\Column(type="string", length=100, nullable=true)
  26. */
  27. private $name;
  28.  
  29. /**
  30. * @ORM\Column(type="datetime", nullable=true)
  31. */
  32. private $birthdate;
  33.  
  34. /**
  35. * @ORM\Column(type="datetime", nullable=true)
  36. */
  37. private $last_login;
  38.  
  39. /**
  40. * @ORM\Column(type="datetime", nullable=true)
  41. */
  42. private $registration;
  43.  
  44. /**
  45. * @ORM\Column(type="string", length=150, nullable=true)
  46. */
  47. private $email;
  48.  
  49. /**
  50. * @ORM\Column(type="string", length=150, nullable=true)
  51. */
  52. private $password;
  53.  
  54. private $passwordConfirm;
  55.  
  56. /**
  57. * @ORM\OneToMany(targetEntity="Car", mappedBy="owner")
  58. */
  59. private $owned_cars;
  60.  
  61. /**
  62. * @ORM\PreUpdate
  63. */
  64. public function updateLastLoginTimeStamp()
  65. {
  66. $this->last_login = new \DateTime(date("Y-m-d H:i:s"));
  67. }
  68.  
  69. /**
  70. * @ORM\PrePersist
  71. */
  72. public function updateRegTimeStamp()
  73. {
  74. if($this->registration == null)
  75. $this->registration = new \DateTime(date("Y-m-d H:i:s"));
  76. }
  77.  
  78.  
  79.  
  80. /**
  81. * Constructor
  82. */
  83. public function __construct()
  84. {
  85. $this->owned_cars = new \Doctrine\Common\Collections\ArrayCollection();
  86. }
  87.  
  88. /**
  89. * Get id
  90. *
  91. * @return integer
  92. */
  93. public function getId()
  94. {
  95. return $this->id;
  96. }
  97.  
  98. /**
  99. * Set name
  100. *
  101. * @param string $name
  102. *
  103. * @return Owner
  104. */
  105. public function setName($name)
  106. {
  107. $this->name = $name;
  108.  
  109. return $this;
  110. }
  111.  
  112. /**
  113. * Get name
  114. *
  115. * @return string
  116. */
  117. public function getName()
  118. {
  119. return $this->name;
  120. }
  121.  
  122. /**
  123. * Set birthdate
  124. *
  125. * @param \DateTime $birthdate
  126. *
  127. * @return Owner
  128. */
  129. public function setBirthdate($birthdate)
  130. {
  131. $this->birthdate = $birthdate;
  132.  
  133. return $this;
  134. }
  135.  
  136. /**
  137. * Get birthdate
  138. *
  139. * @return \DateTime
  140. */
  141. public function getBirthdate()
  142. {
  143. return $this->birthdate;
  144. }
  145.  
  146. /**
  147. * Set lastLogin
  148. *
  149. * @param \DateTime $lastLogin
  150. *
  151. * @return Owner
  152. */
  153. public function setLastLogin($lastLogin)
  154. {
  155. $this->last_login = $lastLogin;
  156.  
  157. return $this;
  158. }
  159.  
  160. /**
  161. * Get lastLogin
  162. *
  163. * @return \DateTime
  164. */
  165. public function getLastLogin()
  166. {
  167. return $this->last_login;
  168. }
  169.  
  170. /**
  171. * Set registration
  172. *
  173. * @param \DateTime $registration
  174. *
  175. * @return Owner
  176. */
  177. public function setRegistration($registration)
  178. {
  179. $this->registration = $registration;
  180.  
  181. return $this;
  182. }
  183.  
  184. /**
  185. * Get registration
  186. *
  187. * @return \DateTime
  188. */
  189. public function getRegistration()
  190. {
  191. return $this->registration;
  192. }
  193.  
  194. /**
  195. * Set email
  196. *
  197. * @param string $email
  198. *
  199. * @return Owner
  200. */
  201. public function setEmail($email)
  202. {
  203. $this->email = $email;
  204.  
  205. return $this;
  206. }
  207.  
  208. /**
  209. * Get email
  210. *
  211. * @return string
  212. */
  213. public function getEmail()
  214. {
  215. return $this->email;
  216. }
  217.  
  218. /**
  219. * Set password
  220. *
  221. * @param string $password
  222. *
  223. * @return Owner
  224. */
  225. public function setPassword($password)
  226. {
  227. $this->password = $password;//password_hash($password, PASSWORD_BCRYPT);
  228.  
  229. return $this;
  230. }
  231.  
  232. /**
  233. * Get password
  234. *
  235. * @return string
  236. */
  237. public function getPassword()
  238. {
  239. return $this->password;
  240. }
  241.  
  242. /**
  243. * Set passwordConfirm
  244. *
  245. * @param string $password
  246. *
  247. * @return Owner
  248. */
  249. public function setPasswordConfirm($passwordConfirm)
  250. {
  251. $this->$passwordConfirm = $passwordConfirm;
  252.  
  253. return $this;
  254. }
  255.  
  256. /**
  257. * Get passwordConfirm
  258. *
  259. * @return string
  260. */
  261. public function getPasswordConfirm()
  262. {
  263. return $this->passwordConfirm;
  264. }
  265.  
  266. /**
  267. * Add ownedCar
  268. *
  269. * @param \AppBundle\Entity\Car $ownedCar
  270. *
  271. * @return Owner
  272. */
  273. public function addOwnedCar(\AppBundle\Entity\Car $ownedCar)
  274. {
  275. $this->owned_cars[] = $ownedCar;
  276.  
  277. return $this;
  278. }
  279.  
  280. /**
  281. * Remove ownedCar
  282. *
  283. * @param \AppBundle\Entity\Car $ownedCar
  284. */
  285. public function removeOwnedCar(\AppBundle\Entity\Car $ownedCar)
  286. {
  287. $this->owned_cars->removeElement($ownedCar);
  288. }
  289.  
  290. /**
  291. * Get ownedCars
  292. *
  293. * @return \Doctrine\Common\Collections\Collection
  294. */
  295. public function getOwnedCars()
  296. {
  297. return $this->owned_cars;
  298. }
  299.  
  300. public function getRoles()
  301. {
  302. return array('ROLE_USER');
  303. }
  304.  
  305. public function eraseCredentials()
  306. {
  307.  
  308. }
  309.  
  310. /** @see \Serializable::serialize() */
  311. public function serialize()
  312. {
  313. return serialize(array(
  314. $this->id,
  315. $this->name,
  316. $this->password,
  317. // see section on salt below
  318. // $this->salt,
  319. ));
  320. }
  321.  
  322. /** @see \Serializable::unserialize() */
  323. public function unserialize($serialized)
  324. {
  325. list (
  326. $this->id,
  327. $this->name,
  328. $this->password,
  329. // see section on salt below
  330. // $this->salt
  331. ) = unserialize($serialized);
  332. }
  333.  
  334. /**
  335. * Returns the salt that was originally used to encode the password.
  336. *
  337. * This can return null if the password was not encoded using a salt.
  338. *
  339. * @return string|null The salt
  340. */
  341. public function getSalt()
  342. {
  343. // TODO: Implement getSalt() method.
  344. }
  345.  
  346. /**
  347. * Returns the username used to authenticate the user.
  348. *
  349. * @return string The username
  350. */
  351. public function getUsername()
  352. {
  353. // TODO: Implement getUsername() method.
  354. }
  355. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement