Laravel hat eine leere Methode namens registriert in Illuminate \ Foundation \ Auth \ RegistersUsers Zug um diesen Vorgang zu vereinfachen, außer Kraft setzen es einfach, wie folgend:
zunächst eine neue Benachrichtigung hinzufügen:
<?php
namespace App\Notifications;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class UserRegisteredNotification extends Notification {
public function __construct($user) {
$this->user = $user;
}
public function via($notifiable) {
return ['mail'];
}
public function toMail($notifiable) {
return (new MailMessage)
->success()
->subject('Welcome')
->line('Dear ' . $this->user->name . ', we are happy to see you here.')
->action('Go to site', url('/'))
->line('Please tell your friends about us.');
}
}
Fügen Sie diese Verwendung Zeile in RegisterController.php:
use App\Notifications\UserRegisteredNotification;
und fügen Sie diese Methode:
protected function registered(Request $request, $user) {
$user->notify(new UserRegisteredNotification($user));
}
Sie fertig sind.
Sehen Sie sich services/registrar.php – Digitlimit