0
この登録メールのキューはとてもシンプルなようですが、どこかで何かを見つけられなくてはなりません!それはここで起こるインスタンス化完全なオブジェクトであってもLaravel 5 Queueディスパッチャがプロパティを使用してインスタンス化しない
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Mail;
use App\Mail\EmailVerification;
use Illuminate\Support\Facades\Log;
class SendVerificationEmail implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $user;
public function __construct($user)
{
$this->user = $user;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$email = new EmailVerification($this->user);
Log::alert('Showing user profile: '.json_encode($this->user));
$user = $this->user;
$to = "[email protected]";
if(isset($user->email)){
$to = $user->email;
}
Mail::to($to)->send($email);
}
}
ます$ this->ユーザープロパティが空である:
public function register(Request $request)
{
$this->validator($request->all())->validate();
event(new Registered($user = $this->create($request->all())));
dd($user); //at this moment $user is everything it's supposed to be;
dispatch(new SendVerificationEmail($user)); // it is now null??
return view('email.verification');
}
ハンドル()関数は、ディスパッチのためのコールバック(ある)が、なぜそれがユーザーオブジェクトを渡されないのですか?
ご協力いただければ幸いです!