src/Entity/System/CustomerNotification.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity\System;
  3. use App\Repository\System\CustomerNotificationRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6. * @ORM\Entity(repositoryClass=CustomerNotificationRepository::class)
  7. *
  8. * @ORM\Table(name="customer_notification")
  9. */
  10. class CustomerNotification
  11. {
  12. /**
  13. * @var int
  14. *
  15. * @ORM\Id
  16. *
  17. * @ORM\GeneratedValue(strategy="AUTO")
  18. *
  19. * @ORM\Column(type="integer")
  20. */
  21. private $id;
  22. /**
  23. * @var Customer
  24. *
  25. * @ORM\ManyToOne(targetEntity="App\Entity\System\Customer")
  26. *
  27. * @ORM\JoinColumn(name="customer_id", referencedColumnName="id_customer", nullable=false)
  28. */
  29. private $customer;
  30. /**
  31. * @var Notification
  32. *
  33. * @ORM\ManyToOne(targetEntity="App\Entity\System\Notification")
  34. *
  35. * @ORM\JoinColumn(name="notification_id", referencedColumnName="id", nullable=false)
  36. */
  37. private $notification;
  38. /**
  39. * @var bool
  40. *
  41. * @ORM\Column(type="boolean", name="`read`")
  42. */
  43. private $read;
  44. /**
  45. * @var int|null
  46. *
  47. * @ORM\Column(type="integer", nullable=true)
  48. */
  49. private $entityId;
  50. public static function createFromNotificationAndCustomer(Customer $customer, Notification $notification, ?int $entityId): CustomerNotification
  51. {
  52. $cm = new self();
  53. $cm->customer = $customer;
  54. $cm->notification = $notification;
  55. $cm->entityId = $entityId;
  56. $cm->read = false;
  57. return $cm;
  58. }
  59. /**
  60. * @return int
  61. */
  62. public function getId(): int
  63. {
  64. return $this->id;
  65. }
  66. /**
  67. * @return Customer
  68. */
  69. public function getCustomer(): Customer
  70. {
  71. return $this->customer;
  72. }
  73. /**
  74. * @return Notification
  75. */
  76. public function getNotification(): Notification
  77. {
  78. return $this->notification;
  79. }
  80. /**
  81. * @return bool
  82. */
  83. public function isRead(): bool
  84. {
  85. return $this->read;
  86. }
  87. /**
  88. * @return int|null
  89. */
  90. public function getEntityId(): ?int
  91. {
  92. return $this->entityId;
  93. }
  94. /**
  95. * @param bool $read
  96. */
  97. public function setRead(bool $read): void
  98. {
  99. $this->read = $read;
  100. }
  101. }