src/Entity/Admin.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\Security\Core\User\UserInterface;
  5. use JMS\Serializer\Annotation\ExclusionPolicy;
  6. use JMS\Serializer\Annotation\Exclude;
  7. use JMS\Serializer\Annotation\Expose;
  8. use JMS\Serializer\Annotation\MaxDepth;
  9. /**
  10. * Admin
  11. *
  12. * @ORM\Table(name="admin", options={"collate"="latin1_general_ci","charset"="latin1"})
  13. * @ORM\Entity(repositoryClass="App\Repository\AdminRepository")
  14. * @ExclusionPolicy("all")
  15. */
  16. class Admin implements UserInterface {
  17. /**
  18. * @var integer
  19. *
  20. * @ORM\Column(name="id", type="integer", nullable=false)
  21. * @ORM\Id
  22. * @ORM\GeneratedValue(strategy="IDENTITY")
  23. * @Expose
  24. */
  25. private $id;
  26. /**
  27. * @var \DateTime
  28. *
  29. * @ORM\Column(name="datefr", type="date", nullable=false)
  30. */
  31. private $datefr;
  32. /**
  33. * @var string
  34. *
  35. * @ORM\Column(name="user", type="string", length=11, nullable=false)
  36. */
  37. private $user;
  38. /**
  39. * @var string
  40. *
  41. * @ORM\Column(name="password", type="string", length=11, nullable=false)
  42. */
  43. private $password;
  44. /**
  45. * @var string
  46. *
  47. * @ORM\Column(name="famille", type="string", length=20, nullable=false)
  48. */
  49. private $famille;
  50. /**
  51. * @var string
  52. *
  53. * @ORM\Column(name="contact", type="string", length=100, nullable=false)
  54. * @Expose
  55. */
  56. private $contact;
  57. /**
  58. * @var \DateTime
  59. *
  60. * @ORM\Column(name="ddn", type="date", nullable=false)
  61. */
  62. private $ddn;
  63. /**
  64. * @var string
  65. *
  66. * @ORM\Column(name="adresse", type="string", length=150, nullable=false)
  67. */
  68. private $adresse;
  69. /**
  70. * @var string
  71. *
  72. * @ORM\Column(name="cp", type="string", length=10, nullable=false)
  73. */
  74. private $cp;
  75. /**
  76. * @var string
  77. *
  78. * @ORM\Column(name="ville", type="string", length=100, nullable=false)
  79. */
  80. private $ville;
  81. /**
  82. * @var string
  83. *
  84. * @ORM\Column(name="tel", type="string", length=30, nullable=false)
  85. */
  86. private $tel;
  87. /**
  88. * @var string
  89. *
  90. * @ORM\Column(name="mobile", type="string", length=30, nullable=false)
  91. */
  92. private $mobile;
  93. /**
  94. * @var string
  95. *
  96. * @ORM\Column(name="email", type="string", length=150, nullable=false)
  97. */
  98. private $email;
  99. /**
  100. * @var float
  101. *
  102. * @ORM\Column(name="commission", type="decimal", nullable=false, precision=8, scale=2)
  103. */
  104. private $commission;
  105. /**
  106. * @var boolean
  107. *
  108. * @ORM\Column(name="valide", type="boolean", nullable=false)
  109. */
  110. private $valide;
  111. /**
  112. * @ORM\OneToMany(targetEntity="App\Entity\Client", mappedBy="idadmin")
  113. */
  114. private $clients;
  115. public function __toString() {
  116. return $this->contact;
  117. }
  118. /**
  119. * Get id
  120. *
  121. * @return integer
  122. */
  123. public function getId() {
  124. return $this->id;
  125. }
  126. /**
  127. * Set datefr
  128. *
  129. * @param \DateTime $datefr
  130. * @return Admin
  131. */
  132. public function setDatefr($datefr) {
  133. $this->datefr = $datefr;
  134. return $this;
  135. }
  136. /**
  137. * Get datefr
  138. *
  139. * @return \DateTime
  140. */
  141. public function getDatefr() {
  142. return $this->datefr;
  143. }
  144. /**
  145. * Set user
  146. *
  147. * @param string $user
  148. * @return Admin
  149. */
  150. public function setUser($user) {
  151. $this->user = $user;
  152. return $this;
  153. }
  154. /**
  155. * Get user
  156. *
  157. * @return string
  158. */
  159. public function getUser() {
  160. return $this->user;
  161. }
  162. /**
  163. * Set password
  164. *
  165. * @param string $password
  166. * @return Admin
  167. */
  168. public function setPassword($password) {
  169. $this->password = $password;
  170. return $this;
  171. }
  172. /**
  173. * Get password
  174. *
  175. * @return string
  176. */
  177. public function getPassword() {
  178. return $this->password;
  179. }
  180. /**
  181. * Set famille
  182. *
  183. * @param string $famille
  184. * @return Admin
  185. */
  186. public function setFamille($famille) {
  187. $this->famille = $famille;
  188. return $this;
  189. }
  190. /**
  191. * Get famille
  192. *
  193. * @return string
  194. */
  195. public function getFamille() {
  196. return $this->famille;
  197. }
  198. /**
  199. * Set contact
  200. *
  201. * @param string $contact
  202. * @return Admin
  203. */
  204. public function setContact($contact) {
  205. $this->contact = $contact;
  206. return $this;
  207. }
  208. /**
  209. * Get contact
  210. *
  211. * @return string
  212. */
  213. public function getContact() {
  214. return $this->contact;
  215. }
  216. /**
  217. * Set ddn
  218. *
  219. * @param \DateTime $ddn
  220. * @return Admin
  221. */
  222. public function setDdn($ddn) {
  223. $this->ddn = $ddn;
  224. return $this;
  225. }
  226. /**
  227. * Get ddn
  228. *
  229. * @return \DateTime
  230. */
  231. public function getDdn() {
  232. return $this->ddn;
  233. }
  234. /**
  235. * Set adresse
  236. *
  237. * @param string $adresse
  238. * @return Admin
  239. */
  240. public function setAdresse($adresse) {
  241. $this->adresse = $adresse;
  242. return $this;
  243. }
  244. /**
  245. * Get adresse
  246. *
  247. * @return string
  248. */
  249. public function getAdresse() {
  250. return $this->adresse;
  251. }
  252. /**
  253. * Set cp
  254. *
  255. * @param string $cp
  256. * @return Admin
  257. */
  258. public function setCp($cp) {
  259. $this->cp = $cp;
  260. return $this;
  261. }
  262. /**
  263. * Get cp
  264. *
  265. * @return string
  266. */
  267. public function getCp() {
  268. return $this->cp;
  269. }
  270. /**
  271. * Set ville
  272. *
  273. * @param string $ville
  274. * @return Admin
  275. */
  276. public function setVille($ville) {
  277. $this->ville = $ville;
  278. return $this;
  279. }
  280. /**
  281. * Get ville
  282. *
  283. * @return string
  284. */
  285. public function getVille() {
  286. return $this->ville;
  287. }
  288. /**
  289. * Set tel
  290. *
  291. * @param string $tel
  292. * @return Admin
  293. */
  294. public function setTel($tel) {
  295. $this->tel = $tel;
  296. return $this;
  297. }
  298. /**
  299. * Get tel
  300. *
  301. * @return string
  302. */
  303. public function getTel() {
  304. return $this->tel;
  305. }
  306. /**
  307. * Set mobile
  308. *
  309. * @param string $mobile
  310. * @return Admin
  311. */
  312. public function setMobile($mobile) {
  313. $this->mobile = $mobile;
  314. return $this;
  315. }
  316. /**
  317. * Get mobile
  318. *
  319. * @return string
  320. */
  321. public function getMobile() {
  322. return $this->mobile;
  323. }
  324. /**
  325. * Set email
  326. *
  327. * @param string $email
  328. * @return Admin
  329. */
  330. public function setEmail($email) {
  331. $this->email = $email;
  332. return $this;
  333. }
  334. /**
  335. * Get email
  336. *
  337. * @return string
  338. */
  339. public function getEmail() {
  340. return $this->email;
  341. }
  342. /**
  343. * Set commission
  344. *
  345. * @param float $commission
  346. * @return Admin
  347. */
  348. public function setCommission($commission) {
  349. $this->commission = $commission;
  350. return $this;
  351. }
  352. /**
  353. * Get commission
  354. *
  355. * @return float
  356. */
  357. public function getCommission() {
  358. return $this->commission;
  359. }
  360. /**
  361. * Set valide
  362. *
  363. * @param boolean $valide
  364. * @return Admin
  365. */
  366. public function setValide($valide) {
  367. $this->valide = $valide;
  368. return $this;
  369. }
  370. /**
  371. * Get valide
  372. *
  373. * @return boolean
  374. */
  375. public function getValide() {
  376. return $this->valide;
  377. }
  378. /**
  379. * Get username
  380. *
  381. * @return string
  382. */
  383. public function getUsername() {
  384. return $this->user;
  385. }
  386. /**
  387. * Get roles
  388. *
  389. * @return array
  390. */
  391. public function getRoles() {
  392. if ($this->valide == 1)
  393. {
  394. $roles = array('ROLE_USER');
  395. if ($this->famille == 'Commercial')
  396. $roles[] = 'ROLE_COMMERCIAL';
  397. else if ($this->famille == 'Admin')
  398. $roles[] = 'ROLE_ADMIN';
  399. return $roles;
  400. }
  401. else
  402. return array();
  403. }
  404. /**
  405. * Get salt
  406. *
  407. * @return string
  408. */
  409. public function getSalt() {
  410. return '';
  411. }
  412. /**
  413. * eraseCredentials
  414. *
  415. * @return string
  416. */
  417. public function eraseCredentials() {
  418. return '';
  419. }
  420. }