Skip to content

Commit aad9304

Browse files
committed
Member can view notes where he received notification from
1 parent 5ede7e1 commit aad9304

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/Models/Comment.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function delete()
3232

3333
// Delete notifications
3434
\DB::table('panichd_comment_email')->where('comment_id', $this->id)->delete();
35-
35+
3636

3737
$error = $a_errors ? implode('. ', $a_errors) : null;
3838
if ($error != "") return $error;
@@ -92,7 +92,18 @@ public function attachments()
9292
public function scopeForLevel($query, $level)
9393
{
9494
// User level
95-
if ($level < 2) return $query->whereIN('type', ['reply', 'complete', 'completetx', 'reopen']);
95+
if ($level < 2){
96+
return $query->where(function($q1){
97+
// Common public comments
98+
return $q1->whereIN('type', ['reply', 'complete', 'completetx', 'reopen'])
99+
->orWhere(function($q2){
100+
$q2->where('type', 'note')->whereHas('notifications', function($q3){
101+
// Notes from where current user has been notified
102+
return $q3->where('member_id', auth()->user()->id);
103+
});
104+
});
105+
});
106+
}
96107

97108
// For agent or admin
98109
return $query;

0 commit comments

Comments
 (0)