feat: implement user registration email notification and add email templates

This commit is contained in:
2025-10-21 18:00:45 +02:00
parent 2c07b0bc0f
commit 7959eec118
5 changed files with 92 additions and 2 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use App\Mail\UserRegistrationCompleted;
use App\Models\Company;
use App\Models\StudentData;
use App\Models\User;
@@ -11,6 +12,7 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
use Mail;
class RegisteredUserController extends Controller
{
@@ -71,10 +73,9 @@ class RegisteredUserController extends Controller
]);
}
Mail::to($user)->sendNow(new UserRegistrationCompleted($user->name, $password));
event(new Registered($user));
Auth::login($user);
return response()->noContent();
}
}

View File

@@ -0,0 +1,61 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailables\Address;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class UserRegistrationCompleted extends Mailable
{
use Queueable, SerializesModels;
private string $name;
private string $password;
/**
* Create a new message instance.
*/
public function __construct(string $name, string $password)
{
$this->name = $name;
$this->password = $password;
}
/**
* Get the message envelope.
*/
public function envelope(): Envelope
{
return new Envelope(
subject: '[ISOP] Účet vytvorený',
);
}
/**
* Get the message content definition.
*/
public function content(): Content
{
return new Content(
view: 'mail.registration.completed',
with: [
"name" => $this->name,
"password" => $this->password
]
);
}
/**
* Get the attachments for the message.
*
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
*/
public function attachments(): array
{
return [];
}
}

View File

@@ -0,0 +1,16 @@
@include("parts.header")
<p>Vážená/ý {{ $name }},</p>
<p>vaša registrácia do systému ISOP UKF prebehla úspešne!</p>
<br />
<p>Vaše heslo je: <em>{{ $password }}</em></p>
<br />
<p>Ďakujeme za vašu registráciu.</p>
<br />
<p>s pozdravom</p>
<p>Systém ISOP UKF</p>
@include("parts.footer")

View File

@@ -0,0 +1,3 @@
</body>
</html>

View File

@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>