0
ログインに成功するたびに通知メールを送信したいと思います。 handleUserWasAuthenticated関数を変更します。これは、正常にログインするときにこの関数が呼び出されると仮定しています。しかし、フォームのデータから$ request変数を通して電子メールとユーザー名を取得することはできません。 $ requestは、デフォルトでhandleUserWasAuthenticated関数内の他の場所でも使用されています。追加されたコードで$ requestが "Variable $ requestは初期化されていないようです"という警告を表示します。メールを送信するためにメールとユーザー名を取得するにはどうすればよいですか?
これは、あなたがこのコードを持っていることを確認しAuthenticatesUser.php
にnamespace Illuminate\Foundation\Auth;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Lang;
trait AuthenticatesUsers
{
use RedirectsUsers;
protected function handleUserWasAuthenticated(Request $request, $throttles)
{
//My modification
$data = [
'title' => 'Welcome to Myfirstsite',
'content' => 'You have finished your registration successfully'
];
Mail::send('emails.verification', $data, function($message){
$message
->to($request['email'],$request['name'])
->subject('Verification email from Myfirstsite');
});
//Original part
if ($throttles) {
$this->clearLoginAttempts($request);
}
if (method_exists($this, 'authenticated')) {
return $this->authenticated($request, Auth::guard($this->getGuard())->user());
}
return redirect()->intended($this->redirectPath());
}
}
'を照らし\のHttp \要求を使用;' AuthenticatesUser 'ですデフォルトでは '.php'です。 –