File: /home/bdedition/www/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));
});
}
}