Compare commits
1 Commits
feature/ex
...
feature/Up
| Author | SHA1 | Date | |
|---|---|---|---|
| 4afcd5c81e |
@@ -30,6 +30,7 @@ ENV COMPOSER_ALLOW_SUPERUSER=1
|
||||
# Default command
|
||||
CMD composer install ;\
|
||||
composer dump-autoload --optimize --classmap-authoritative ;\
|
||||
php artisan key:generate ;\
|
||||
php artisan migrate ;\
|
||||
php artisan db:seed ;\
|
||||
php-fpm
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Resources\ExpertResource;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Traits\ApiResponse;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function info(): JsonResponse
|
||||
{
|
||||
return $this->successResponse(new ExpertResource(Auth::user()));
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Admin\Resources;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
|
||||
class ExpertResource extends JsonResource
|
||||
{
|
||||
/**
|
||||
* Transform the resource into an array.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toArray(Request $request): array
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'username' => $this->username,
|
||||
'email' => $this->email,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
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/Http/Controllers/AuthController.php → backend/app/User/Controller/Auth/AuthController.php
Normal file → Executable file
14
backend/app/Http/Controllers/AuthController.php → backend/app/User/Controller/Auth/AuthController.php
Normal file → Executable file
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
namespace App\User\Controller\Auth;
|
||||
|
||||
use App\Http\Requests\Auth\LoginRequest;
|
||||
use App\Http\Requests\Auth\RegisterRequest;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Traits\ApiResponse;
|
||||
use App\User\Requests\Auth\LoginRequest;
|
||||
use App\User\Requests\Auth\RegisterRequest;
|
||||
use App\User\Resources\UserResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
@@ -44,11 +46,7 @@ class AuthController extends Controller
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
return $this->successResponse([
|
||||
'id' => $user->id,
|
||||
'username' => $user->username,
|
||||
'email' => $user->email,
|
||||
]);
|
||||
return $this->successResponse(new UserResource($user));
|
||||
}
|
||||
|
||||
return $this->errorResponse(__('messages.incorrect_or_username_password'));
|
||||
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)
|
||||
);
|
||||
}
|
||||
}
|
||||
5
backend/app/Http/Requests/Auth/LoginRequest.php → backend/app/User/Requests/Auth/LoginRequest.php
Normal file → Executable file
5
backend/app/Http/Requests/Auth/LoginRequest.php → backend/app/User/Requests/Auth/LoginRequest.php
Normal file → Executable file
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
namespace App\User\Requests\Auth;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class LoginRequest extends FormRequest
|
||||
@@ -18,7 +17,7 @@ class LoginRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
5
backend/app/Http/Requests/Auth/RegisterRequest.php → backend/app/User/Requests/Auth/RegisterRequest.php
Normal file → Executable file
5
backend/app/Http/Requests/Auth/RegisterRequest.php → backend/app/User/Requests/Auth/RegisterRequest.php
Normal file → Executable file
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\Auth;
|
||||
namespace App\User\Requests\Auth;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class RegisterRequest extends FormRequest
|
||||
@@ -18,7 +17,7 @@ class RegisterRequest extends FormRequest
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
@@ -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',
|
||||
];
|
||||
|
||||
0
backend/app/User/Resources/UserResource.php
Normal file → Executable file
0
backend/app/User/Resources/UserResource.php
Normal file → Executable file
@@ -12,8 +12,11 @@ return Application::configure(basePath: dirname(__DIR__))
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->web()->preventRequestForgery(['*']);
|
||||
$middleware->web()->validateCsrfTokens(['*']);
|
||||
})
|
||||
->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>
|
||||
@@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
use App\User\Controller\Auth\AuthController;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/user', function (Request $request) {
|
||||
return $request->user();
|
||||
})->middleware('auth:api');
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\AuthController;
|
||||
use App\User\Controller\Auth\AuthController;
|
||||
use App\User\Controller\ProfileController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user