HEX
Server: LiteSpeed
System: Linux srv1.dhviews.com 5.14.0-570.23.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 24 11:27:16 EDT 2025 x86_64
User: bdedition (1723)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/bdedition/public_html/core/app/Traits/UserNotify.php
<?php

namespace App\Traits;

use App\Constants\Status;

trait UserNotify
{
    public static function notifyToUser()
    {
        return [
            'allUsers'              => 'All Staffs',
            'selectedUsers'         => 'Selected Staffs',
            'twoFaDisableUsers'     => '2FA Disable Staffs',
            'twoFaEnableUsers'      => '2FA Enable Staffs',
            'approvedNewsUsers'     => 'Approved News Staffs',
            'pendingNewsUsers'      => 'Pending News Staffs',
            'rejectedNewsUsers'     => 'Rejected News Staffs',
            'pendingTicketUser'     => 'Pending Ticket Staffs',
            'answerTicketUser'      => 'Answer Ticket Staffs',
            'closedTicketUser'      => 'Closed Ticket Staffs',
            'notLoginUsers'         => 'Last Few Days Not Login Staffs',
        ];
    }

    public function scopeSelectedUsers($query)
    {
        return $query->whereIn('id', request()->user ?? []);
    }

    public function scopeAllUsers($query)
    {
        return $query;
    }

    public function scopeTwoFaDisableUsers($query)
    {
        return $query->where('ts', Status::DISABLE);
    }

    public function scopeTwoFaEnableUsers($query)
    {
        return $query->where('ts', Status::ENABLE);
    }

    public function scopeApprovedNewsUsers($query)
    {
        return $query->whereHas('news', function ($q) {
            $q->approved();
        });
    }

    public function scopePendingNewsUsers($query)
    {
        return $query->whereHas('news', function ($q) {
            $q->pending();
        });
    }

    public function scopeRejectedNewsUsers($query)
    {
        return $query->whereHas('news', function ($q) {
            $q->rejected();
        });
    }

    public function scopePendingTicketUser($query)
    {
        return $query->whereHas('tickets', function ($q) {
            $q->whereIn('status', [Status::TICKET_OPEN, Status::TICKET_REPLY]);
        });
    }

    public function scopeClosedTicketUser($query)
    {
        return $query->whereHas('tickets', function ($q) {
            $q->where('status', Status::TICKET_CLOSE);
        });
    }

    public function scopeAnswerTicketUser($query)
    {
        return $query->whereHas('tickets', function ($q) {

            $q->where('status', Status::TICKET_ANSWER);
        });
    }

    public function scopeNotLoginUsers($query)
    {
        return $query->whereDoesntHave('loginLogs', function ($q) {
            $q->whereDate('created_at', '>=', now()->subDays(request()->number_of_days ?? 10));
        });
    }
}