Notification.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace MGModule\DNSManager2\models\custom\notification;
  3. use MGModule\DNSManager2 as main;
  4. /**
  5. * Log class
  6. *
  7. * @Table(name=notification)
  8. */
  9. class Notification extends main\mgLibs\models\orm{
  10. /**
  11. * ID field
  12. *
  13. * @Column(id)
  14. * @var int
  15. */
  16. public $id;
  17. /**
  18. *
  19. * @Column(varchar)
  20. * @var string
  21. */
  22. public $name;
  23. /**
  24. *
  25. * @Column(text)
  26. * @var string
  27. */
  28. public $value;
  29. /**
  30. *
  31. * @Column(int)
  32. * @var string
  33. */
  34. public $type;
  35. /**
  36. *
  37. * @Column(int)
  38. * @var string
  39. */
  40. public $read;
  41. /**
  42. *
  43. * @Column(datetime)
  44. * @var string
  45. */
  46. public $date;
  47. //TODO: wywalic setType (sprawdzic czy nie uzywane)
  48. public function setType($type) {
  49. if(!NotificationTypeEnum::isValidValue($type))
  50. throw new Exception ("Wrong type provided");
  51. $this->type = $type;
  52. }
  53. public function save($data = array()) {
  54. if(!NotificationTypeEnum::isValidValue($this->type)) {
  55. throw new \Exception('Invalid Notification Type');
  56. }
  57. if(!NotificationNameEnum::isValidValue($this->name)) {
  58. throw new \Exception('Invalid Notification Name');
  59. }
  60. parent::save($data);
  61. }
  62. }