66 lines
1.9 KiB
PHP
66 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs\Mail;
|
|
|
|
use App\Mail\PasswordReset;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
class PasswordRecoverJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public array $data;
|
|
public $customer;
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($data = [],$customer = [])
|
|
{
|
|
$this->data = $data;
|
|
$this->customer = $customer;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
try {
|
|
$email = new PasswordReset($this->data);
|
|
Mail::to($this->customer->email)->send($email);
|
|
\App\Models\Mail::create([
|
|
'template_id' => 4,
|
|
'subject' => $email->envelope()->subject,
|
|
'to' => $this->customer->email,
|
|
'customer_id' => $this->customer->id,
|
|
'message' => $email->render()
|
|
]);
|
|
}catch (\Exception $error)
|
|
{
|
|
throw new \Exception($error->getMessage());
|
|
}
|
|
}
|
|
public function failed(\Throwable $exception)
|
|
{
|
|
Log::channel('Custom')->info("\r\n");
|
|
Log::channel('Custom')->info("=================================");
|
|
Log::channel('Custom')->info("Thông báo lỗi lúc: " .Carbon::now());
|
|
Log::channel('Custom')->info("Notification Create VirtualMachine: ");
|
|
Log::channel('Custom')->info("========");
|
|
Log::channel('Custom')->info($exception->getMessage());
|
|
Log::channel('Custom')->info("=================================");
|
|
|
|
}
|
|
}
|