Laravelで初めて通知および郵便サービスを使用しようとしています。私はLaravelを使用しています。5.4MailGun、通知 - Laravel 5.4を使用して電子メール通知を送信する
Laravel 5.2+には、パスワードリセットなどを処理するボックスからの通知という新機能があります。
は、だから私は、次のために、ユーザーに電子メールを送信することを計画しています:1)時のユーザー登録者はパスワードのためのユーザーの要求が
3)時のユーザーをリセットする初めて
2)についてユーザーが友達リクエストを受け付け最後に、レポート問題
4)時のユーザーのセンドの友達リクエスト
5)。
これを進める方法について少し混乱し、迷っています。 MailGunはすべて設定されており、この時点でPostmanを使用して写真に通知を出さずにテスト電子メールを送信することができます。私は通知サービスをセットアップして、2つのものを用意しています:
通知とメールの連携の仕組みは分かりませんか?または私は誰にも固執する必要がありますか?
パスワードリセットフォームにメールを入力すると、現在エラーが発生しています。
エラー
ReflectionException in Container.php line 681:
Class App\Http\Controllers\ResetPasswordController does not exist
フォーム
<form id="msform" role="form" method="POST" action="{{ url('/api/reset') }}">
{{ csrf_field() }}
<fieldset>
<h2 class="fs-title">Enter Password Reset Details</h2>
<h3 class="fs-subtitle">Easy as That !</h3>
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<div class="col-md-6">
<input id="email" type="email" class="form-control" name="email" placeholder="Email Address" value="{{ old('email') }}" required>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
</div>
<div class="form-group">
<input type="submit" name="submit" class="submit action-button" value="Reset"/>
</div>
</fieldset>
</form>
ルート
Route::post('api/reset', '[email protected]');
ResetPasswordのコントローラー
public function send(Request $request)
{
$user = Auth::user()->email;
$user->notify(new WelcomeUser());
Mail::send('emails.passwordreset', function ($message)
{
$message->from('[email protected]', 'Admin - John Doe');
$message->to('[email protected]');
$message->subject('Password Reset');
});
return response()->json(['message' => 'Request completed']);
}
Userモデル
use Illuminate\Notifications\Notifiable;
public function routeNotificationForMail()
{
return $this->email;
}
通知
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class WelcomeUser extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['mail'];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
return (new MailMessage)
->line("Welcome User!")
->action('Let\'s Login', route('auth.login'))
->line("Let's get going!");
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}