Your IP : 216.73.216.79


Current Path : /var/www/html/ebookingdbkl/backend/modules/serviceApplication/queue/
Upload File :
Current File : /var/www/html/ebookingdbkl/backend/modules/serviceApplication/queue/NotificationEmailJob.php

<?php
namespace backend\modules\serviceApplication\queue;
use backend\modules\serviceApplication\models\Notification;
use yii\base\BaseObject;

class NotificationEmailJob extends BaseObject implements \yii\queue\JobInterface
{
    public $ref_id;
    
    public $ref_code;
    
    public $body;
    
    public $recipient;

    public $recipient_cc;
    
    public function execute($queue)
    {
        try {
            $noti = Notification::email($this->ref_id, $this->ref_code, $this->body, $this->recipient, $this->recipient_cc);

            if(!$noti) {
                throw new \Exception("Error Sending Email.. :- please check body->content, body->subject is set.");
            }
        } catch (\Throwable $t) {
            $this->body['error'] = $t->getMessage();
            
            $noti = new Notification();
            $noti->reference_id = $this->ref_id;
            $noti->reference_code = $this->ref_code;
            $noti->subject = $this->body['subject'];
            $noti->body = json_encode($this->body);
            $noti->recipient = json_encode($this->recipient);
            $noti->type = 'EMAIL';
            $noti->status = 'FAILED';
            $noti->save();
        }
    }
}

?>