43 lines
923 B
PHP
43 lines
923 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Mail\SendEmailCode;
|
|
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 SendMail implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
protected $type, $data;
|
|
/**
|
|
* Create a new job instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct($type, $data=null)
|
|
{
|
|
$this->type = $type;
|
|
$this->data = $data;
|
|
}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function handle()
|
|
{
|
|
switch ($this->type) {
|
|
case "code":
|
|
Mail::send(new SendEmailCode($this->data['email']));
|
|
}
|
|
}
|
|
}
|