Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.99 KB | None | 0 0
  1. <?php
  2. namespace Entities;
  3.  
  4.  
  5. use Entities\Repositories,
  6. Entities\Repositories\AdminUserRepository;
  7. /**
  8. * AdminUser
  9. *
  10. * @Table(name="admin_user")
  11. * @Entity(repositoryClass="Entities\Repositories\AdminUserRepository")
  12. */
  13. class AdminUser
  14. {
  15.  
  16. const ACCOUNT_STATUS_ACTIVE = 1;
  17. const ACCOUNT_STATUS_PENDING = 2;
  18. const ACCOUNT_STATUS_DISABLED = 3;
  19.  
  20. protected $accountStatusNames = array(
  21. self::ACCOUNT_STATUS_ACTIVE => 'active',
  22. self::ACCOUNT_STATUS_PENDING => 'pending',
  23. self::ACCOUNT_STATUS_DISABLED => 'disabled'
  24. );
  25.  
  26. /**
  27. * @var integer $id
  28. *
  29. * @Column(name="id", type="integer", length=4)
  30. * @Id
  31. * @GeneratedValue(strategy="IDENTITY")
  32. */
  33. private $id;
  34.  
  35. /**
  36. * @var integer $role_id
  37. *
  38. * @Column(name="role_id", type="integer", length=4)
  39. * @OneToOne(targetEntity="Role")
  40. */
  41. private $role_id;
  42.  
  43. /**
  44. * @var string $email_address
  45. *
  46. * @Column(name="email_address", type="string", length=255)
  47. */
  48. private $email_address;
  49.  
  50. /**
  51. * @var string $password
  52. *
  53. * @Column(name="password", type="string", length=50)
  54. */
  55. private $password;
  56.  
  57. /**
  58. * @var string $title
  59. *
  60. * @Column(name="title", type="string", length=4, nullable=true)
  61. */
  62. private $title;
  63.  
  64. /**
  65. * @var string $first_name
  66. *
  67. * @Column(name="first_name", type="string", length=50)
  68. */
  69. private $first_name;
  70.  
  71. /**
  72. * @var string $last_name
  73. *
  74. * @Column(name="last_name", type="string", length=50)
  75. */
  76. private $last_name;
  77.  
  78. /**
  79. * @var string $company_name
  80. *
  81. * @Column(name="company_name", type="string", length=255, nullable=true)
  82. */
  83. private $company_name;
  84.  
  85. /**
  86. * @var string $telephone_number
  87. *
  88. * @Column(name="telephone_number", type="string", length=20, nullable=true)
  89. */
  90. private $telephone_number;
  91.  
  92. /**
  93. * @var string $account_status
  94. *
  95. * @Column(name="account_status", type="integer", length=4)
  96. */
  97. private $account_status;
  98.  
  99. /**
  100. * @var datetime $date_created
  101. *
  102. * @Column(name="date_created", type="datetime", nullable=true)
  103. */
  104. private $date_created;
  105.  
  106. /**
  107. * @var datetime $last_updated
  108. *
  109. * @Column(name="last_updated", type="datetime", nullable=true)
  110. */
  111. private $last_updated;
  112.  
  113.  
  114. /**
  115. * Get id
  116. *
  117. * @return integer $id
  118. */
  119. public function getId()
  120. {
  121. return $this->id;
  122. }
  123.  
  124. /**
  125. * Set role_id
  126. *
  127. * @param string $roleId
  128. */
  129. public function setRoleId($roleId)
  130. {
  131. $this->role_id = $roleId;
  132. }
  133.  
  134. /**
  135. * Get role_id
  136. *
  137. * @return string $roleId
  138. */
  139. public function getRoleId()
  140. {
  141. return $this->role_id;
  142. }
  143.  
  144. /**
  145. * Set email_address
  146. *
  147. * @param string $emailAddress
  148. */
  149. public function setEmailAddress($emailAddress)
  150. {
  151. $this->email_address = $emailAddress;
  152. }
  153.  
  154. /**
  155. * Get email_address
  156. *
  157. * @return string $emailAddress
  158. */
  159. public function getEmailAddress()
  160. {
  161. return $this->email_address;
  162. }
  163.  
  164. /**
  165. * Set password
  166. *
  167. * @param string $password
  168. */
  169. public function setPassword($password)
  170. {
  171. $this->password = md5($password . AdminUserRepository::getSecretCode());
  172. }
  173.  
  174. /**
  175. * Get password
  176. *
  177. * @return string $password
  178. */
  179. public function getPassword()
  180. {
  181. return $this->password;
  182. }
  183.  
  184. /**
  185. * Set title
  186. *
  187. * @param string $title
  188. */
  189. public function setTitle($title)
  190. {
  191. $this->title = $title;
  192. }
  193.  
  194. /**
  195. * Get title
  196. *
  197. * @return string $title
  198. */
  199. public function getTitle()
  200. {
  201. return $this->title;
  202. }
  203.  
  204. /**
  205. * Set first_name
  206. *
  207. * @param string $firstName
  208. */
  209. public function setFirstName($firstName)
  210. {
  211. $this->first_name = $firstName;
  212. }
  213.  
  214. /**
  215. * Get first_name
  216. *
  217. * @return string $firstName
  218. */
  219. public function getFirstName()
  220. {
  221. return $this->first_name;
  222. }
  223.  
  224. /**
  225. * Set last_name
  226. *
  227. * @param string $lastName
  228. */
  229. public function setLastName($lastName)
  230. {
  231. $this->last_name = $lastName;
  232. }
  233.  
  234. /**
  235. * Get last_name
  236. *
  237. * @return string $lastName
  238. */
  239. public function getLastName()
  240. {
  241. return $this->last_name;
  242. }
  243.  
  244. /**
  245. * Set company_name
  246. *
  247. * @param string $companyName
  248. */
  249. public function setCompanyName($companyName)
  250. {
  251. $this->company_name = $companyName;
  252. }
  253.  
  254. /**
  255. * Get company_name
  256. *
  257. * @return string $companyName
  258. */
  259. public function getCompanyName()
  260. {
  261. return $this->company_name;
  262. }
  263.  
  264. /**
  265. * Set telephone_number
  266. *
  267. * @param string $telephoneNumber
  268. */
  269. public function setTelephoneNumber($telephoneNumber)
  270. {
  271. $this->telephone_number = $telephoneNumber;
  272. }
  273.  
  274. /**
  275. * Get telephone_number
  276. *
  277. * @return string $telephoneNumber
  278. */
  279. public function getTelephoneNumber()
  280. {
  281. return $this->telephone_number;
  282. }
  283.  
  284. /**
  285. * Set account_status
  286. *
  287. * @param string $accountStatus
  288. */
  289. public function setAccountStatus($accountStatus)
  290. {
  291. $this->account_status = $accountStatus;
  292. }
  293.  
  294. /**
  295. * Get account_status
  296. *
  297. * @return string $accountStatus
  298. */
  299. public function getAccountStatus()
  300. {
  301. return $this->account_status;
  302. }
  303.  
  304. /**
  305. * Set date_created
  306. *
  307. * @param datetime $dateCreated
  308. */
  309. public function setDateCreated($dateCreated)
  310. {
  311. $this->date_created = $dateCreated;
  312. }
  313.  
  314. /**
  315. * Get date_created
  316. *
  317. * @return datetime $dateCreated
  318. */
  319. public function getDateCreated()
  320. {
  321. return $this->date_created;
  322. }
  323.  
  324. /**
  325. * Set last_updated
  326. *
  327. * @param datetime $lastUpdated
  328. */
  329. public function setLastUpdated($lastUpdated)
  330. {
  331. $this->last_updated = $lastUpdated;
  332. }
  333.  
  334. /**
  335. * Get last_updated
  336. *
  337. * @return datetime $lastUpdated
  338. */
  339. public function getLastUpdated()
  340. {
  341. return $this->last_updated;
  342. }
  343. }
  344.  
  345.  
  346.  
  347.  
  348.  
  349. <?php
  350. namespace Entities;
  351.  
  352.  
  353. /**
  354. * Role
  355. *
  356. * @Table(name="role")
  357. * @Entity(repositoryClass="Entities\Repositories\RoleRepository")
  358. */
  359. class Role
  360. {
  361.  
  362. const STATUS_ACTIVE = 1;
  363. const STATUS_DISABLED = 2;
  364.  
  365. protected $statusNames = array(
  366. self::STATUS_ACTIVE => 'active',
  367. self::STATUS_DISABLED => 'disabled'
  368. );
  369.  
  370. /**
  371. * @var integer $id
  372. *
  373. * @Column(name="id", type="integer", length=4)
  374. * @Id
  375. * @GeneratedValue(strategy="IDENTITY")
  376. */
  377. private $id;
  378.  
  379. /**
  380. * @var string $name
  381. *
  382. * @Column(name="name", type="string", length=255)
  383. */
  384. private $name;
  385.  
  386. /**
  387. * @var integer $parent_id
  388. *
  389. * @Column(name="parent_id", type="integer", length=4, nullable=true)
  390. */
  391. private $parent_id;
  392.  
  393.  
  394. /**
  395. * @var string $status
  396. * @Column(name="status", type="integer", length=4)
  397. */
  398. private $status;
  399.  
  400.  
  401. public function __construct()
  402. {
  403. // Set default values
  404. $this->setStatus(1);
  405. }
  406.  
  407. /**
  408. * Get id
  409. *
  410. * @return integer $id
  411. */
  412. public function getId()
  413. {
  414. return $this->id;
  415. }
  416.  
  417. /**
  418. * Set name
  419. *
  420. * @param string $name
  421. */
  422. public function setName($name)
  423. {
  424. $this->name = $name;
  425. }
  426.  
  427. /**
  428. * Get name
  429. *
  430. * @return string $name
  431. */
  432. public function getName()
  433. {
  434. return $this->name;
  435. }
  436.  
  437. /**
  438. * Set parent_id
  439. *
  440. * @param integer $parentId
  441. */
  442. public function setParentId($parentId)
  443. {
  444. $this->parent_id = $parentId;
  445. }
  446.  
  447. /**
  448. * Get parent_id
  449. *
  450. * @return integer $parentId
  451. */
  452. public function getParentId()
  453. {
  454. return $this->parent_id;
  455. }
  456.  
  457. /**
  458. * Set status
  459. *
  460. * @param integer $status
  461. */
  462. public function setStatus($status)
  463. {
  464. $this->status = $status;
  465. }
  466.  
  467. /**
  468. * Get status
  469. *
  470. * @return integer $status
  471. */
  472. public function getStatus()
  473. {
  474. return $this->status;
  475. }
  476.  
  477. }
  478.  
  479.  
  480. $qb = $this->em->createQueryBuilder()
  481. ->select('a, r')
  482. ->from('Entities\AdminUser', 'a')
  483. ->leftJoin('a.role_id', 'r');
  484. $query = $qb->getQuery();
  485.  
  486. $user = $query->getResult(Doctrine\ORM\Query::HYDRATE_ARRAY);
  487. var_dump($user);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement