diff --git a/src/Entity/JobOrder.php b/src/Entity/JobOrder.php index 718c70ee..4bfcbcf5 100644 --- a/src/Entity/JobOrder.php +++ b/src/Entity/JobOrder.php @@ -346,6 +346,12 @@ class JobOrder */ protected $date_status_change; + // notifications for this job order + /** + * @ORM\OneToMany(targetEntity="Notification", mappedBy="job_order") + */ + protected $jo_notifications; + public function __construct() { $this->date_create = new DateTime(); @@ -368,6 +374,8 @@ class JobOrder $this->meta = []; $this->phone_mobile = ''; + + $this->jo_notifications = new ArrayCollection(); } public function getID() @@ -996,4 +1004,9 @@ class JobOrder return $this->jo_extra; } + public function getNotifications() + { + return $this->jo_notifications; + } + } diff --git a/src/Entity/Notification.php b/src/Entity/Notification.php new file mode 100644 index 00000000..f24f967c --- /dev/null +++ b/src/Entity/Notification.php @@ -0,0 +1,134 @@ +flag_read = false; + $this->date_create = new DateTime(); + } + + public function getID() + { + return $this->id; + } + + public function setDateCreate(DateTime $date_create) + { + $this->date_create = $date_create; + return $this; + } + + public function getDateCreate() + { + return $this->date_create; + } + + public function isNotificationRead() + { + return $this->flag_read; + } + + public function setReadNotification($bool = true) + { + $this->flag_read = $bool; + return $this; + } + + public function setUser(User $user) + { + $this->user = $user; + return $this; + } + + public function getUser() + { + return $this->user; + } + + public function setJobOrder(JobOrder $jo) + { + $this->job_order = $jo; + return $this; + } + + public function getJobOrder() + { + return $this->job_order; + } + + public function setNotificationType($notif_type) + { + $this->notif_type = $notif_type; + return $this; + } + + public function getNotificationType() + { + return $this->notif_type; + } + + public function getNotficationTypeName() + { + return NotificationType::getName($this->notif_type); + } + +} diff --git a/src/Entity/User.php b/src/Entity/User.php index a57afb97..be0d59f2 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -110,6 +110,18 @@ class User extends BaseUser implements Serializable */ protected $partners_created; + // notifications for this user + /** + * @ORM\OneToMany(targetEntity="Notification", mappedBy="user", indexBy="id") + */ + protected $user_notifications; + + // flag to check if user has read notifications + /** + * @ORM\Column(type="boolean") + */ + protected $flag_read_notifications; + public function __construct() { parent::__construct(); @@ -119,6 +131,9 @@ class User extends BaseUser implements Serializable $this->job_orders_assigned = new ArrayCollection(); $this->tickets = new ArrayCollection(); $this->partners_created = new ArrayCollection(); + $this->user_notifications = new ArrayCollection(); + + $this->flag_read_notifications = false; } public function getID() @@ -309,4 +324,21 @@ class User extends BaseUser implements Serializable { return $this->partners_created; } + + public function getNotifications() + { + return $this->user_notifications; + } + + public function isNotificationsRead() + { + return $this->flag_read_notifications; + } + + public function setReadNotifications($bool = true) + { + $this->flag_read_notifications = $bool; + return $this; + } + }