feature/ForgotPassword #29
40
backend/app/Mail/LoginNotificationMail.php
Normal file
40
backend/app/Mail/LoginNotificationMail.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Mail\Mailables\Content;
|
||||
use Illuminate\Mail\Mailables\Envelope;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class LoginNotificationMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public function __construct(
|
||||
public User $user
|
||||
) {
|
||||
//
|
||||
}
|
||||
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: 'Login Notification Mail',
|
||||
);
|
||||
}
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
return new Content(
|
||||
view: 'emails.login-notification',
|
||||
);
|
||||
}
|
||||
|
||||
public function attachments(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
}
|
||||
14
backend/app/User/Controller/Dashboard/ConfirmController.php
Executable file
14
backend/app/User/Controller/Dashboard/ConfirmController.php
Executable file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Controller\Dashboard;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ConfirmController extends Controller
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -30,10 +30,10 @@ class ProfileController extends Controller
|
||||
'national_id' => $request->national_id,
|
||||
'address' => $request->address,
|
||||
'postal_code' => $request->postal_code,
|
||||
'account_number' => $request->account_number,
|
||||
'phone_number' => $request->phone_number,
|
||||
'province_id' => $request->province_id,
|
||||
'city_id' => $request->city_id,
|
||||
'status' => 1
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
|
||||
23
backend/app/User/Events/LoginEmailEvent.php
Executable file
23
backend/app/User/Events/LoginEmailEvent.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Events;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Broadcasting\Channel;
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Broadcasting\PrivateChannel;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class LoginEmailEvent
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new event instance.
|
||||
*/
|
||||
public function __construct(public User $user)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
31
backend/app/User/Listeners/SendEmailListener.php
Executable file
31
backend/app/User/Listeners/SendEmailListener.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Listeners;
|
||||
|
||||
use App\Mail\LoginNotificationMail;
|
||||
use App\User\Events\LoginEmailEvent;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendEmailListener implements ShouldQueue{
|
||||
public string $queue = 'emails';
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(LoginEmailEvent $event): void
|
||||
{
|
||||
$user = $event->user;
|
||||
|
||||
Mail::to($user->email)->send(
|
||||
new LoginNotificationMail($user)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,7 @@ class EditRequest extends FormRequest
|
||||
'national_id' => 'required',
|
||||
'address' => 'required',
|
||||
'postal_code' => 'required',
|
||||
'account_number' => 'required',
|
||||
'phone_number' => 'required|regex:/^964\d{9}$/|numeric|digits:11',
|
||||
'phone_number' => 'required',
|
||||
'province_id' => 'required',
|
||||
'city_id' => 'required',
|
||||
];
|
||||
|
||||
@@ -16,4 +16,7 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
//
|
||||
})->create();
|
||||
})
|
||||
->withEvents(discover: [
|
||||
__DIR__.'/../app/User/Listeners',
|
||||
])->create();
|
||||
|
||||
24
backend/resources/views/emails/login-notification.blade.php
Normal file
24
backend/resources/views/emails/login-notification.blade.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Login Notification</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>Hello {{ $user->username }}</h2>
|
||||
|
||||
<p>You have successfully logged in to your account.</p>
|
||||
|
||||
<p>
|
||||
Email: {{ $user->email }}
|
||||
</p>
|
||||
|
||||
<p>
|
||||
If this login was not done by you, please contact support immediately.
|
||||
</p>
|
||||
|
||||
<br>
|
||||
|
||||
<p>Thank you.</p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user