api code global jain
This commit is contained in:
78
app/Jobs/CertificateRejectionJob.php
Normal file
78
app/Jobs/CertificateRejectionJob.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Constant\Constant;
|
||||
use App\Mail\CertificateRejectionForPatientMail;
|
||||
use App\Models\UserDeviceToken;
|
||||
use App\Traits\PushNotificationTraits;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldBeUnique;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class CertificateRejectionJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels , PushNotificationTraits;
|
||||
|
||||
protected $certificate;
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($certificate)
|
||||
{
|
||||
$this->certificate = $certificate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
//Patient
|
||||
$email = new CertificateRejectionForPatientMail($this->certificate);
|
||||
Mail::to($this->certificate->email)->queue($email);
|
||||
|
||||
//Push Notification to user on comment
|
||||
$tokens = UserDeviceToken::where('user_id', $this->certificate->user_id)->get()->toArray();
|
||||
$pushData = [];
|
||||
$users = [];
|
||||
|
||||
if($tokens && $tokens > 0) {
|
||||
foreach ($tokens as $token) {
|
||||
$pushData['userToken'] = $token['token'] ?? [];
|
||||
$pushData['title'] = "JHC Letter Status";
|
||||
$pushData['body'] = "JHC letter rejected, please review and resubmit.";
|
||||
$extraData = [];
|
||||
$extraData['type'] = "JHCStatus";
|
||||
$extraData['os'] = $token['os'] ? getPlatform($token['os']) : [];
|
||||
|
||||
$pushData['extraData'] = $extraData ?? [];
|
||||
$this->pushNotification($pushData, $extraData);
|
||||
}
|
||||
}
|
||||
//Store Notification
|
||||
$notificationData = [];
|
||||
$notificationData['body'] = "JHC letter rejected, please review and resubmit.";
|
||||
$notificationData['type'] = "JHCStatus";
|
||||
$notificationData['title'] = "JHC Letter Status";
|
||||
$extraNotificationData = [];
|
||||
$notificationData['user_id'] = $this->certificate->user_id ?? '';
|
||||
$extraNotificationData['notification_type'] = Constant::STATUS_ONE;
|
||||
$notificationData['extraNotificationData'] = $extraNotificationData ?? [];
|
||||
|
||||
if (!in_array($this->certificate->user_id, $users)) {
|
||||
$users[$this->certificate->user_id] = $this->certificate->user_id;
|
||||
$this->storeNotification($notificationData);
|
||||
//Unread count increment
|
||||
unreadNotificationCounter($this->certificate->user_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user