diff --git a/app/Http/Controllers/UsersController.php b/app/Http/Controllers/UsersController.php index 307dd20..ecda185 100644 --- a/app/Http/Controllers/UsersController.php +++ b/app/Http/Controllers/UsersController.php @@ -2,10 +2,12 @@ namespace App\Http\Controllers; +use App\Mail\RegisterUserMail; use App\Models\User; use Illuminate\Http\Request; use Illuminate\Mail\Mailable; use Illuminate\Support\Facades\Hash; +use Illuminate\Support\Facades\Mail; use SebastianBergmann\CodeCoverage\Report\Xml\Project; class UsersController extends Controller @@ -26,7 +28,7 @@ class UsersController extends Controller $user->save(); dispatch(function () use ($user) { - Mail::to($user->email)->send(new Mailable()); + Mail::to($user->email)->send(new RegisterUserMail($user->name)); }); return ['token' => $user->createToken(name:'frontend')->plainTextToken]; diff --git a/app/Mail/AdminNewUserNotification.php b/app/Mail/AdminNewUserNotification.php new file mode 100644 index 0000000..6e8f63b --- /dev/null +++ b/app/Mail/AdminNewUserNotification.php @@ -0,0 +1,57 @@ +name = $name; + $this->email = $email; + } + + + /** + * Get the message envelope. + */ + public function envelope(): Envelope + { + return new Envelope( + subject: 'Новый пользователь зарегистрировался', + ); + } + + /** + * Get the message content definition. + */ + public function content(): Content + { + return new Content( + view: 'emails.admin_new_user', + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/app/Mail/RegisterUserMail.php b/app/Mail/RegisterUserMail.php new file mode 100644 index 0000000..e359d86 --- /dev/null +++ b/app/Mail/RegisterUserMail.php @@ -0,0 +1,54 @@ +name = $name; + } + + /** + * Get the message envelope. + */ + public function envelope(): Envelope + { + return new Envelope( + subject: 'Регистрация завершена', + ); + } + + /** + * Get the message content definition. + */ + public function content(): Content + { + return new Content( + view: 'emails.register', + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/resources/views/emails/admin_new_user.blade.php b/resources/views/emails/admin_new_user.blade.php new file mode 100644 index 0000000..e7867f3 --- /dev/null +++ b/resources/views/emails/admin_new_user.blade.php @@ -0,0 +1,8 @@ + + + +

На сайте зарегистрировался новый пользователь

+

Имя: {{ $name }}

+

Email: {{ $email }}

+ + \ No newline at end of file diff --git a/resources/views/emails/register.blade.php b/resources/views/emails/register.blade.php new file mode 100644 index 0000000..c9d170f --- /dev/null +++ b/resources/views/emails/register.blade.php @@ -0,0 +1,7 @@ + + + +

Привет, "{{ $name }}"!

+

Спасибо за регистрацию на нашем сайте.

+ + \ No newline at end of file