Advertisement
raphaelluiz128

users

Jun 21st, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php
  2. namespace App\Model\Entity;
  3.  
  4. use Cake\ORM\Entity;
  5. use Cake\Auth\DefaultPasswordHasher;
  6. /**
  7. * User Entity
  8. *
  9. * @property int $id
  10. * @property string $name
  11. * @property string $username
  12. * @property string $email
  13. * @property string $password
  14. * @property int $roles_id
  15. * @property \Cake\I18n\FrozenTime $created
  16. * @property \Cake\I18n\FrozenTime $modified
  17. *
  18. * @property \App\Model\Entity\Role $role
  19. */
  20. class User extends Entity
  21. {
  22.  
  23. /**
  24. * Fields that can be mass assigned using newEntity() or patchEntity().
  25. *
  26. * Note that when '*' is set to true, this allows all unspecified fields to
  27. * be mass assigned. For security purposes, it is advised to set '*' to false
  28. * (or remove it), and explicitly make individual fields accessible as needed.
  29. *
  30. * @var array
  31. */
  32. protected $_accessible = [
  33. 'name' => true,
  34. 'username' => true,
  35. 'email' => true,
  36. 'password' => true,
  37. 'roles_id' => true,
  38. 'created' => true,
  39. 'modified' => true,
  40. 'role' => true
  41. ];
  42.  
  43. /**
  44. * Fields that are excluded from JSON versions of the entity.
  45. *
  46. * @var array
  47. */
  48. protected $_hidden = [
  49. 'password'
  50. ];
  51.  
  52. protected function _setPassword($password)
  53. {
  54. if (strlen($password) > 0)
  55. return (new DefaultPasswordHasher)->hash($password);
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement