Skip to content

Commit a4bc5fe

Browse files
committed
Patch: Correct some member Model references
1 parent 430eee5 commit a4bc5fe

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/Models/Member.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,9 @@ public function canCloseTicket($id)
244244
*/
245245
public function canCommentTicket($ticket)
246246
{
247-
if (\PanicHDMember::canManageTicket($ticket->id)
248-
or \PanicHDMember::isTicketOwner($ticket->id)
249-
or $ticket->commentNotifications()->where('member_id', auth()->user()->id)->count() > 0) {
247+
if ($this->canManageTicket($ticket->id)
248+
or $this->isTicketOwner($ticket->id)
249+
or $ticket->commentNotifications()->where('member_id', $this->id)->count() > 0) {
250250
return true;
251251
}
252252

@@ -463,12 +463,16 @@ public function scopeVisible($query)
463463
{
464464
$query = $query->agents();
465465

466-
if (auth()->user()->panichd_admin) {
466+
$member = \PanicHDMember::findOrFail(auth()->user()->id);
467+
468+
if ($member->panichd_admin) {
467469
return $query->orderBy('name', 'ASC');
468-
} elseif (auth()->user()->panichd_agent) {
469-
return $query->VisibleForAgent(auth()->user()->id);
470+
471+
} elseif ($member->panichd_agent) {
472+
return $query->VisibleForAgent($member->id);
473+
470474
} else {
471-
return $query->where('1', '=', '0');
475+
return $query->where('id', '0');
472476
}
473477
}
474478

@@ -482,7 +486,9 @@ public function scopeVisible($query)
482486
*/
483487
public function scopeVisibleForAgent($query, $id)
484488
{
485-
if ($this->currentLevel() == 2) {
489+
$member = \PanicHDMember::findOrFail(auth()->user()->id);
490+
491+
if ($member->currentLevel() == 2) {
486492
// Depends on agent_restrict
487493
if (Setting::grab('agent_restrict') == 0) {
488494
return $query->whereHas('categories', function ($q1) use ($id) {

0 commit comments

Comments
 (0)