0
對我來說,這個註冊郵件隊列看起來很簡單,我必須在某處丟失一些東西!Laravel 5 Queue Dispatcher沒有用屬性實例化
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);
}
}
的$這個 - >用戶屬性爲空,即使它被實例化時發生在這裏完整的對象:
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');
}
句柄()函數是調度的回調(),但爲什麼它不通過用戶對象?
任何幫助將不勝感激!