| @@ -129,5 +129,26 @@ | ||
| 129 | 129 | 'notification_id' |
| 130 | 130 | )->withTimestamps() |
| 131 | 131 | ->withPivot('marked_read_at'); |
| 132 | 132 | } |
| 133 | + public function assignedTasks() | |
| 134 | + { | |
| 135 | + return $this->belongsToMany( | |
| 136 | + Task::class, | |
| 137 | + 'fbs_relations', | |
| 138 | + 'foreign_id', | |
| 139 | + 'object_id' | |
| 140 | + )->withPivot('settings') | |
| 141 | + ->wherePivot('object_type', Constant::OBJECT_TYPE_TASK_ASSIGNEE) | |
| 142 | + ->withTimestamps(); | |
| 143 | + } | |
| 144 | + | |
| 145 | + public function mentionedTasks() | |
| 146 | + { | |
| 147 | + return Task::whereHas('notifications', function ($query) { | |
| 148 | + $query->where('action', 'task_comment_mentioned') | |
| 149 | + ->whereHas('users', function ($q) { | |
| 150 | + $q->where('user_id', $this->ID); | |
| 151 | + }); | |
| 152 | + }); | |
| 153 | + } | |
| 133 | 154 | } |