Compare commits
29 Commits
feature/Ed
...
feature/Fo
| Author | SHA1 | Date | |
|---|---|---|---|
| 99d24c38c7 | |||
| 9a01a83370 | |||
| 8438655f8c | |||
| 5040299efc | |||
| 26a0f79a6d | |||
| 1b5d339a53 | |||
| c73d50d096 | |||
| 8be89d350f | |||
| d31c641216 | |||
| aa363d1695 | |||
| ca2ec66fb5 | |||
| 5c757e1823 | |||
| d9f895c382 | |||
| 9ad3d6cea0 | |||
| 8554f4cc55 | |||
| 5e48777e1c | |||
| 738b21e182 | |||
| 77a4e98058 | |||
| 01bae8474b | |||
| 463ca3f006 | |||
| 1ba141e715 | |||
| 76e6ab4e0c | |||
| fb35ed58b1 | |||
| ffb4179e0d | |||
| a7fa1097b7 | |||
| f2f9d38907 | |||
| 5b79cefe28 | |||
| 41b7ead69e | |||
| 5ea986db40 |
@@ -16,19 +16,6 @@ class AuthController extends Controller
|
|||||||
{
|
{
|
||||||
use ApiResponse;
|
use ApiResponse;
|
||||||
|
|
||||||
public function register(RegisterRequest $request): JsonResponse
|
|
||||||
{
|
|
||||||
Expert::query()->create([
|
|
||||||
'username' => $request->username,
|
|
||||||
'email' => $request->email,
|
|
||||||
'password' => Hash::make($request->password),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$request->session()->regenerate();
|
|
||||||
|
|
||||||
return $this->successResponse();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function login(LoginRequest $request): JsonResponse
|
public function login(LoginRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$credentials = ['password' => $request->password];
|
$credentials = ['password' => $request->password];
|
||||||
@@ -39,8 +26,7 @@ class AuthController extends Controller
|
|||||||
$credentials['username'] = $request->login;
|
$credentials['username'] = $request->login;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Auth::attempt($credentials))
|
if (Auth::guard('expert')->attempt($credentials)) {
|
||||||
{
|
|
||||||
$request->session()->regenerate();
|
$request->session()->regenerate();
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ namespace App\Admin\Controllers;
|
|||||||
|
|
||||||
use App\Admin\Requests\ExpertManagement\StoreRequest;
|
use App\Admin\Requests\ExpertManagement\StoreRequest;
|
||||||
use App\Admin\Requests\ExpertManagement\UpdateRequest;
|
use App\Admin\Requests\ExpertManagement\UpdateRequest;
|
||||||
use App\Admin\Resources\ExpertManagementResource;
|
|
||||||
use App\Facades\DataTable\DataTableFacade;
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\City;
|
use App\Models\City;
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Admin\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\Auth\PasswordResetOtpService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class ForgotPasswordOtpController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly PasswordResetOtpService $otpService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function sendOtp(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'email' => ['required', 'email', 'exists:users,email'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$email = $validated['email'];
|
||||||
|
|
||||||
|
$key = 'user-forgot-password-otp:' . $email . ':' . $request->ip();
|
||||||
|
|
||||||
|
if (RateLimiter::tooManyAttempts($key, 3)) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => ['Too many OTP requests. Please try again later.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RateLimiter::hit($key, 600);
|
||||||
|
|
||||||
|
$user = User::query()->where('email', $email)->firstOrFail();
|
||||||
|
|
||||||
|
$this->otpService->sendOtp($user, 'user');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'OTP sent to your email.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifyOtp(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'email' => ['required', 'email', 'exists:users,email'],
|
||||||
|
'otp' => ['required', 'digits:6'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->otpService->verifyOtp(
|
||||||
|
email: $validated['email'],
|
||||||
|
otp: $validated['otp'],
|
||||||
|
guard: 'user'
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'OTP verified successfully.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetPassword(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'email' => ['required', 'email', 'exists:users,email'],
|
||||||
|
'password' => ['required', 'confirmed',],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$record = $this->otpService->ensureVerified(
|
||||||
|
email: $validated['email'],
|
||||||
|
guard: 'user'
|
||||||
|
);
|
||||||
|
|
||||||
|
$user = User::query()->where('email', $validated['email'])->firstOrFail();
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$record->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'User password reset successfully.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,6 @@ class EditRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
$user = $this->user();
|
|
||||||
return [
|
return [
|
||||||
'username' => 'string|max:255',
|
'username' => 'string|max:255',
|
||||||
'first_name' => 'required|string',
|
'first_name' => 'required|string',
|
||||||
|
|||||||
66
backend/app/Enums/BusinessTypeEnum.php
Normal file
66
backend/app/Enums/BusinessTypeEnum.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum BusinessTypeEnum: int
|
||||||
|
{
|
||||||
|
case MEDICAL = 1;
|
||||||
|
case LEGAL = 2;
|
||||||
|
case ENGINEERING = 3;
|
||||||
|
case EDUCATION = 4;
|
||||||
|
case CONSULTING = 5;
|
||||||
|
case BEAUTY = 6;
|
||||||
|
case TECHNICAL_SERVICES = 7;
|
||||||
|
case FINANCIAL = 8;
|
||||||
|
case REAL_ESTATE = 9;
|
||||||
|
case RESTAURANT = 10;
|
||||||
|
case SHOP = 11;
|
||||||
|
case TRANSPORTATION = 12;
|
||||||
|
case ART = 13;
|
||||||
|
case SPORT = 14;
|
||||||
|
case OTHER = 15;
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::MEDICAL => 'medical',
|
||||||
|
self::LEGAL => 'legal',
|
||||||
|
self::ENGINEERING => 'engineering',
|
||||||
|
self::EDUCATION => 'education',
|
||||||
|
self::CONSULTING => 'consulting',
|
||||||
|
self::BEAUTY => 'beauty',
|
||||||
|
self::TECHNICAL_SERVICES => 'technical_services',
|
||||||
|
self::FINANCIAL => 'financial',
|
||||||
|
self::REAL_ESTATE => 'real_estate',
|
||||||
|
self::RESTAURANT => 'restaurant',
|
||||||
|
self::SHOP => 'shop',
|
||||||
|
self::TRANSPORTATION => 'transportation',
|
||||||
|
self::ART => 'art',
|
||||||
|
self::SPORT => 'sport',
|
||||||
|
self::OTHER => 'other',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function name($id): string
|
||||||
|
{
|
||||||
|
$mapArray = [
|
||||||
|
1 => 'medical',
|
||||||
|
2 => 'legal',
|
||||||
|
3 => 'engineering',
|
||||||
|
4 => 'education',
|
||||||
|
5 => 'consulting',
|
||||||
|
6 => 'beauty',
|
||||||
|
7 => 'technical_services',
|
||||||
|
8 => 'financial',
|
||||||
|
9 => 'real_estate',
|
||||||
|
10 => 'restaurant',
|
||||||
|
11 => 'shop',
|
||||||
|
12 => 'transportation',
|
||||||
|
13 => 'art',
|
||||||
|
14 => 'sport',
|
||||||
|
15 => 'other',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $mapArray[$id];
|
||||||
|
}
|
||||||
|
}
|
||||||
23
backend/app/Enums/PaymentStatusEnum.php
Normal file
23
backend/app/Enums/PaymentStatusEnum.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Enums;
|
||||||
|
|
||||||
|
enum PaymentStatusEnum:int
|
||||||
|
{
|
||||||
|
case Unpaid = 0;
|
||||||
|
case Cancelled = 1;
|
||||||
|
case Expired = 2;
|
||||||
|
case Paid = 3;
|
||||||
|
case Refunded = 4;
|
||||||
|
|
||||||
|
public function label(): string
|
||||||
|
{
|
||||||
|
return match ($this) {
|
||||||
|
self::Unpaid => 'unpaid',
|
||||||
|
self::Cancelled => 'cancelled',
|
||||||
|
self::Expired => 'expired',
|
||||||
|
self::Paid => 'paid',
|
||||||
|
self::Refunded => 'refunded',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Database\Factories\GatewayCategoryFactory;
|
use Database\Factories\BusinessTypeFactory;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class GatewayCategory extends Model
|
class BusinessType extends Model
|
||||||
{
|
{
|
||||||
/** @use HasFactory<GatewayCategoryFactory> */
|
/** @use HasFactory<BusinessTypeFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
@@ -5,17 +5,19 @@ namespace App\Models;
|
|||||||
use Database\Factories\ExpertFactory;
|
use Database\Factories\ExpertFactory;
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Notifications\Notifiable;
|
||||||
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||||
use Spatie\Permission\Traits\HasRoles;
|
use Spatie\Permission\Traits\HasRoles;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method roles()
|
* @method roles()
|
||||||
* @method permissions()
|
* @method permissions()
|
||||||
*/
|
*/
|
||||||
class Expert extends Model
|
class Expert extends Authenticatable
|
||||||
{
|
{
|
||||||
/** @use HasFactory<ExpertFactory> */
|
/** @use HasFactory<ExpertFactory> */
|
||||||
use HasFactory;
|
|
||||||
use HasRoles;
|
use Notifiable,HasFactory,HasRoles;
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
protected string $guard_name = 'web';
|
protected string $guard_name = 'web';
|
||||||
|
|||||||
@@ -2,13 +2,12 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Database\Factories\GatewayFactory;
|
|
||||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Gateway extends Model
|
class FibTransaction extends Model
|
||||||
{
|
{
|
||||||
/** @use HasFactory<GatewayFactory> */
|
/** @use HasFactory<\Database\Factories\FibTransactionFactory> */
|
||||||
use HasFactory;
|
use HasFactory;
|
||||||
|
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
12
backend/app/Models/FibTransactionStatus.php
Normal file
12
backend/app/Models/FibTransactionStatus.php
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class FibTransactionStatus extends Model
|
||||||
|
{
|
||||||
|
/** @use HasFactory<\Database\Factories\FibTransactionStatusFactory> */
|
||||||
|
use HasFactory;
|
||||||
|
}
|
||||||
10
backend/app/Models/PasswordResetOtp.php
Normal file
10
backend/app/Models/PasswordResetOtp.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class PasswordResetOtp extends Model
|
||||||
|
{
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
}
|
||||||
15
backend/app/Models/Transaction.php
Normal file
15
backend/app/Models/Transaction.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Database\Factories\TransactionFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class Transaction extends Model
|
||||||
|
{
|
||||||
|
/** @use HasFactory<TransactionFactory> */
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
}
|
||||||
15
backend/app/Models/UserGateway.php
Normal file
15
backend/app/Models/UserGateway.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Database\Factories\UserGatewayFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class UserGateway extends Model
|
||||||
|
{
|
||||||
|
/** @use HasFactory<UserGatewayFactory> */
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $guarded = ['id'];
|
||||||
|
}
|
||||||
32
backend/app/Notifications/ResetPasswordOtpNotification.php
Normal file
32
backend/app/Notifications/ResetPasswordOtpNotification.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Notifications;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
|
use Illuminate\Notifications\Notification;
|
||||||
|
|
||||||
|
class ResetPasswordOtpNotification extends Notification
|
||||||
|
{
|
||||||
|
use Queueable;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
private readonly string $otp
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function via(object $notifiable): array
|
||||||
|
{
|
||||||
|
return ['mail'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function toMail(object $notifiable): MailMessage
|
||||||
|
{
|
||||||
|
return (new MailMessage)
|
||||||
|
->subject('Reset Password OTP')
|
||||||
|
->greeting('Hello!')
|
||||||
|
->line('Your password reset code is:')
|
||||||
|
->line($this->otp)
|
||||||
|
->line('This code will expire in 10 minutes.')
|
||||||
|
->line('If you did not request password reset, ignore this email.');
|
||||||
|
}
|
||||||
|
}
|
||||||
103
backend/app/Services/Auth/PasswordResetOtpService.php
Normal file
103
backend/app/Services/Auth/PasswordResetOtpService.php
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Auth;
|
||||||
|
|
||||||
|
use App\Models\PasswordResetOtp;
|
||||||
|
use App\Notifications\ResetPasswordOtpNotification;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class PasswordResetOtpService
|
||||||
|
{
|
||||||
|
public function sendOtp(Model $user, string $guard = 'user'): void
|
||||||
|
{
|
||||||
|
$otp = (string) random_int(100000, 999999);
|
||||||
|
|
||||||
|
PasswordResetOtp::query()->where('email', $user->email)
|
||||||
|
->where('guard', $guard)
|
||||||
|
->delete();
|
||||||
|
|
||||||
|
PasswordResetOtp::query()->create([
|
||||||
|
'email' => $user->email,
|
||||||
|
'guard' => $guard,
|
||||||
|
'otp' => Hash::make($otp),
|
||||||
|
'expires_at' => now()->addMinutes(10),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->notify(new ResetPasswordOtpNotification($otp));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifyOtp(string $email, string $otp, string $guard = 'user'): void
|
||||||
|
{
|
||||||
|
$record = PasswordResetOtp::query()->where('email', $email)
|
||||||
|
->where('guard', $guard)
|
||||||
|
->latest()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $record) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'otp' => ['Invalid OTP.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($record->isExpired()) {
|
||||||
|
$record->delete();
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'otp' => ['OTP has expired.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($record->attempts >= 5) {
|
||||||
|
$record->delete();
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'otp' => ['Too many wrong attempts. Please request a new OTP.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! Hash::check($otp, $record->otp)) {
|
||||||
|
$record->increment('attempts');
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'otp' => ['Invalid OTP.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$record->update([
|
||||||
|
'verified_at' => now(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ensureVerified(string $email, string $guard = 'user'): PasswordResetOtp
|
||||||
|
{
|
||||||
|
$record = PasswordResetOtp::query()->where('email', $email)
|
||||||
|
->where('guard', $guard)
|
||||||
|
->latest()
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (! $record || ! $record->isVerified()) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'otp' => ['Please verify OTP first.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($record->isExpired()) {
|
||||||
|
$record->delete();
|
||||||
|
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'otp' => ['OTP has expired.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $record;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteOtp(string $email, string $guard = 'user'): void
|
||||||
|
{
|
||||||
|
PasswordResetOtp::query()->where('email', $email)
|
||||||
|
->where('guard', $guard)
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -16,7 +16,7 @@ class AuthorizationService
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->url = config('fib.authorization.url');
|
$this->url = config('fib.authorization.url');
|
||||||
$this->channelName = '';
|
$this->channelName = 'fib_authorization';
|
||||||
$this->inputParameters = [
|
$this->inputParameters = [
|
||||||
'client_id' => config('fib.authorization.client_id'),
|
'client_id' => config('fib.authorization.client_id'),
|
||||||
'client_secret' => config('fib.authorization.client_secret'),
|
'client_secret' => config('fib.authorization.client_secret'),
|
||||||
@@ -51,7 +51,6 @@ class AuthorizationService
|
|||||||
{
|
{
|
||||||
return Http::asForm()
|
return Http::asForm()
|
||||||
->throw()
|
->throw()
|
||||||
->withoutVerifying()
|
|
||||||
->post($this->url, $this->inputParameters)
|
->post($this->url, $this->inputParameters)
|
||||||
->json();
|
->json();
|
||||||
}
|
}
|
||||||
|
|||||||
86
backend/app/Services/FIB/FIBClient.php
Executable file
86
backend/app/Services/FIB/FIBClient.php
Executable file
@@ -0,0 +1,86 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\FIB;
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
|
||||||
|
class FIBClient
|
||||||
|
{
|
||||||
|
|
||||||
|
public $auth_service;
|
||||||
|
public $create_payment_service;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function client()
|
||||||
|
{
|
||||||
|
return Http::acceptJson()
|
||||||
|
->contentType('application/json')
|
||||||
|
->withToken($this->getAccessToken())
|
||||||
|
->timeout(30);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAccessToken()
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
if ($this->isNotProduction()) {
|
||||||
|
return json_decode(
|
||||||
|
file_get_contents(storage_path('app/mock/fib/token.json'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$response = Http::withOptions([
|
||||||
|
'proxy' => 'http://host.docker.internal:10808',
|
||||||
|
])->asForm()->post('https://fib-stage.fib.iq/auth/realms/fib-online-shop/protocol/openid-connect/token', [
|
||||||
|
'grant_type' => 'client_credentials',
|
||||||
|
'client_id' => 'ipay-test-payment',
|
||||||
|
'client_secret' => '8dae3180-f39c-448e-8b45-a01c8f4c8c15',
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
throw new \Exception(
|
||||||
|
'Unable to authenticate with FIB: ' .
|
||||||
|
$response->body()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $response->json();
|
||||||
|
|
||||||
|
if (!isset($data['access_token'])) {
|
||||||
|
throw new \Exception('FIB token missing in response');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data['access_token'];
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
return $exception->getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createPaymentService()
|
||||||
|
{
|
||||||
|
if ($this->isNotProduction()) {
|
||||||
|
return json_decode(
|
||||||
|
file_get_contents(storage_path('app/mock/fib/payment_create_success.json'))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$response = $this->client()->post("https://fib-stage.fib.iq/protected/v1/payments");
|
||||||
|
if ($response->failed()) {
|
||||||
|
throw new \Exception(
|
||||||
|
'Unable to authenticate with FIB: ' .
|
||||||
|
$response->body()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $response->json();
|
||||||
|
if (!isset($data['paymentId'])) {
|
||||||
|
throw new \Exception('FIB paymentId missing in response');
|
||||||
|
}
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function isNotProduction()
|
||||||
|
{
|
||||||
|
return env('APP_ENV') === 'local';
|
||||||
|
}
|
||||||
|
}
|
||||||
38
backend/app/Services/Payments/DTO/FIBPaymentCreateDTO.php
Normal file
38
backend/app/Services/Payments/DTO/FIBPaymentCreateDTO.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Payments\DTO;
|
||||||
|
|
||||||
|
class FIBPaymentCreateDTO
|
||||||
|
{
|
||||||
|
public string $paymentId;
|
||||||
|
public string $readableCode;
|
||||||
|
public string $qrCode;
|
||||||
|
public string $validUntil;
|
||||||
|
public string $personalAppLink;
|
||||||
|
public string $businessAppLink;
|
||||||
|
public string $corporateAppLink;
|
||||||
|
|
||||||
|
public function __construct(array $data)
|
||||||
|
{
|
||||||
|
$this->paymentId = $data['paymentId'];
|
||||||
|
$this->readableCode = $data['readableCode'];
|
||||||
|
$this->qrCode = $data['qrCode'];
|
||||||
|
$this->validUntil = $data['validUntil'];
|
||||||
|
$this->personalAppLink = $data['personalAppLink'];
|
||||||
|
$this->businessAppLink = $data['businessAppLink'];
|
||||||
|
$this->corporateAppLink = $data['corporateAppLink'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromResponse($data): FIBPaymentCreateDTO
|
||||||
|
{
|
||||||
|
return new self([
|
||||||
|
'paymentId' => $data->paymentId,
|
||||||
|
'readableCode' => $data->readableCode,
|
||||||
|
'qrCode' => $data->qrCode,
|
||||||
|
'validUntil' => $data->validUntil,
|
||||||
|
'personalAppLink' => $data->personalAppLink,
|
||||||
|
'businessAppLink' => $data->businessAppLink,
|
||||||
|
'corporateAppLink' => $data->corporateAppLink,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
46
backend/app/Services/Payments/DTO/PaymentCreateDTO.php
Normal file
46
backend/app/Services/Payments/DTO/PaymentCreateDTO.php
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Payments\DTO;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class PaymentCreateDTO
|
||||||
|
{
|
||||||
|
|
||||||
|
public string $username;
|
||||||
|
public int $user_id;
|
||||||
|
public string $track_id;
|
||||||
|
public string $amount;
|
||||||
|
public string $currency;
|
||||||
|
public string $callback_url;
|
||||||
|
public string $ip;
|
||||||
|
public int $user_gateway_id;
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct(array $data)
|
||||||
|
{
|
||||||
|
$this->username = $data['username'];
|
||||||
|
$this->user_id = $data['user_id'];
|
||||||
|
$this->track_id = $data['track_id'];
|
||||||
|
$this->amount = $data['amount'];
|
||||||
|
$this->currency = $data['currency'];
|
||||||
|
$this->callback_url = $data['callback_url'];
|
||||||
|
$this->ip = $data['ip'];
|
||||||
|
$this->user_gateway_id = $data['user_gateway_id'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function fromRequest(Request $request): PaymentCreateDTO
|
||||||
|
{
|
||||||
|
return new self([
|
||||||
|
'username' => $request->username,
|
||||||
|
'user_id' => '2',
|
||||||
|
'track_id' => uuid_create(),
|
||||||
|
'amount' => $request->amount,
|
||||||
|
'currency' => $request->currency,
|
||||||
|
'callback_url' => $request->callback_url,
|
||||||
|
'ip' => $request->getClientIp(),
|
||||||
|
'user_gateway_id' => $request->user_gateway_id,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
37
backend/app/Services/Payments/FibAdapter.php
Normal file
37
backend/app/Services/Payments/FibAdapter.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Payments;
|
||||||
|
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Services\FIB\CreatePaymentService;
|
||||||
|
use App\Services\FIB\FIBClient;
|
||||||
|
|
||||||
|
class FibAdapter
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private CreatePaymentService $create_payment_service,
|
||||||
|
private FIBClient $fib_client
|
||||||
|
)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createPayment(array $data)
|
||||||
|
{
|
||||||
|
Payment::query()->create([
|
||||||
|
'user_id' => auth()->id(),
|
||||||
|
'username' => $data['username'],
|
||||||
|
'track_id' => $data['track_id'],
|
||||||
|
'amount' => $data['amount'],
|
||||||
|
'currency' => $data['currency'],
|
||||||
|
'callback_url' => $data['callback_url'],
|
||||||
|
'expires_at' => $data['expires_at'],
|
||||||
|
'status_id' => $data['status_id'],
|
||||||
|
'status_name' => $data['status_name'],
|
||||||
|
'ip' => $data['ip'],
|
||||||
|
'user_gateway_id' => $data['user_gateway_id'],
|
||||||
|
'created_at' => $data['created_at'],
|
||||||
|
'updated_at' => $data['updated_at'],
|
||||||
|
]);
|
||||||
|
$this->fib_client->client();
|
||||||
|
}
|
||||||
|
}
|
||||||
72
backend/app/Services/Payments/PaymentService.php
Normal file
72
backend/app/Services/Payments/PaymentService.php
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Services\Payments;
|
||||||
|
|
||||||
|
use App\Enums\PaymentStatusEnum;
|
||||||
|
use App\Models\FibTransaction;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Models\Transaction;
|
||||||
|
use App\Services\FIB\FIBClient;
|
||||||
|
use App\Services\Payments\DTO\FIBPaymentCreateDTO;
|
||||||
|
use App\Services\Payments\DTO\PaymentCreateDTO;
|
||||||
|
|
||||||
|
class PaymentService
|
||||||
|
{
|
||||||
|
public $fib_client;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->fib_client = new FibClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createPayment(PaymentCreateDTO $dto)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$payment = Payment::query()->create([
|
||||||
|
'user_id' => $dto->user_id,
|
||||||
|
'username' => $dto->username,
|
||||||
|
'track_id' => $dto->track_id,
|
||||||
|
'amount' => $dto->amount,
|
||||||
|
'currency' => $dto->currency,
|
||||||
|
'callback_url' => $dto->callback_url,
|
||||||
|
'status_id' => PaymentStatusEnum::Unpaid->value,
|
||||||
|
'status_name' => PaymentStatusEnum::Unpaid->name,
|
||||||
|
'ip' => $dto->ip,
|
||||||
|
'user_gateway_id' => $dto->user_gateway_id,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$response = $this->fib_client->createPaymentService();
|
||||||
|
$fib_response_dto = FIBPaymentCreateDTO::fromResponse($response);
|
||||||
|
|
||||||
|
$transaction = Transaction::query()->create([
|
||||||
|
'user_id' => $payment->user_id,
|
||||||
|
'amount' => $payment->amount,
|
||||||
|
'currency' => $payment->currency,
|
||||||
|
'callback_url' => $payment->callback_url,
|
||||||
|
// 'description' => '',
|
||||||
|
// 'expires_in' => '',
|
||||||
|
'payment_id' => $payment->id,
|
||||||
|
'payment_track_id' => $payment->track_id,
|
||||||
|
'user_gateway_id' => $payment->user_gateway_id,
|
||||||
|
// 'status' => '',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$fib_transactions = FibTransaction::query()->create([
|
||||||
|
'transaction_id' => $transaction->id,
|
||||||
|
'qrcode' => $fib_response_dto->qrCode,
|
||||||
|
'readable_code' => $fib_response_dto->readableCode,
|
||||||
|
'personalAppLink' => $fib_response_dto->personalAppLink,
|
||||||
|
'businessAppLink' => $fib_response_dto->businessAppLink,
|
||||||
|
'corporateAppLink' => $fib_response_dto->corporateAppLink,
|
||||||
|
'paymentId' => $fib_response_dto->paymentId,
|
||||||
|
'paymentMethod' => 'fib',
|
||||||
|
'validUntil' => $fib_response_dto->validUntil,
|
||||||
|
'status_id' => PaymentStatusEnum::Unpaid->value,
|
||||||
|
'status_name' => PaymentStatusEnum::Unpaid->name,
|
||||||
|
]);
|
||||||
|
return $payment;
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
throw new \Exception($exception->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
backend/app/User/Controllers/CityController.php
Executable file
24
backend/app/User/Controllers/CityController.php
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\City;
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Traits\ApiResponse;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class CityController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function list(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$cities = City::query()
|
||||||
|
->where('province_id', '=', $request->query('province_id'))
|
||||||
|
->get(['id', 'name']);
|
||||||
|
|
||||||
|
return $this->successResponse($cities);
|
||||||
|
}
|
||||||
|
}
|
||||||
89
backend/app/User/Controllers/ForgotPasswordOtpController.php
Normal file
89
backend/app/User/Controllers/ForgotPasswordOtpController.php
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Expert;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Services\Auth\PasswordResetOtpService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Illuminate\Support\Facades\RateLimiter;
|
||||||
|
use Illuminate\Validation\ValidationException;
|
||||||
|
|
||||||
|
class ForgotPasswordOtpController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private readonly PasswordResetOtpService $otpService
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function sendOtp(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'email' => ['required', 'email', 'exists:experts,email'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$email = $validated['email'];
|
||||||
|
|
||||||
|
$key = 'expert-forgot-password-otp:' . $email . ':' . $request->ip();
|
||||||
|
|
||||||
|
if (RateLimiter::tooManyAttempts($key, 3)) {
|
||||||
|
throw ValidationException::withMessages([
|
||||||
|
'email' => ['Too many OTP requests. Please try again later.'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
RateLimiter::hit($key, 600);
|
||||||
|
|
||||||
|
$expert = Expert::query()->where('email', $email)->firstOrFail();
|
||||||
|
|
||||||
|
$this->otpService->sendOtp($expert, 'expert');
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'OTP sent to your email.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function verifyOtp(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'email' => ['required', 'email', 'exists:experts,email'],
|
||||||
|
'otp' => ['required', 'digits:6'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->otpService->verifyOtp(
|
||||||
|
email: $validated['email'],
|
||||||
|
otp: $validated['otp'],
|
||||||
|
guard: 'expert'
|
||||||
|
);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'OTP verified successfully.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resetPassword(Request $request): JsonResponse
|
||||||
|
{
|
||||||
|
$validated = $request->validate([
|
||||||
|
'email' => ['required', 'email', 'exists:experts,email'],
|
||||||
|
'password' => ['required', 'confirmed'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
$record = $this->otpService->ensureVerified(
|
||||||
|
email: $validated['email'],
|
||||||
|
guard: 'expert'
|
||||||
|
);
|
||||||
|
|
||||||
|
$expert = Expert::query()->where('email', $validated['email'])->firstOrFail();
|
||||||
|
|
||||||
|
$expert->update([
|
||||||
|
'password' => Hash::make($validated['password']),
|
||||||
|
]);
|
||||||
|
|
||||||
|
$record->delete();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'message' => 'Expert password reset successfully.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
97
backend/app/User/Controllers/GatewayManagementController.php
Normal file
97
backend/app/User/Controllers/GatewayManagementController.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controllers;
|
||||||
|
|
||||||
|
use App\Enums\BusinessTypeEnum;
|
||||||
|
use App\Facades\DataTable\DataTableFacade;
|
||||||
|
use App\Facades\File\FileFacade;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\UserGateway;
|
||||||
|
use App\Traits\ApiResponse;
|
||||||
|
use App\User\Requests\Gateway\StoreRequest;
|
||||||
|
use App\User\Requests\Gateway\UpdateRequest;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
|
class GatewayManagementController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public function index(Request $request)
|
||||||
|
{
|
||||||
|
return DataTableFacade::run(
|
||||||
|
UserGateway::query()->where('user_id', '=', Auth::guard('web')->id()),
|
||||||
|
$request,
|
||||||
|
allowedFilters: ['*'],
|
||||||
|
allowedSortings: ['*'],
|
||||||
|
allowedSelects: ['id', 'name', 'domain', 'tax_id', 'bank_name', 'account_holder', 'iban', 'business_type_id', 'business_type_name'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
|
public function store(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
$user = Auth::guard('web')->user();
|
||||||
|
|
||||||
|
$logo = $request->has('logo') ? FileFacade::save($request->file('logo'), "{$user->id}") : null;
|
||||||
|
|
||||||
|
DB::transaction(function () use ($user, $logo, $request) {
|
||||||
|
UserGateway::query()->create([
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'username' => $user->username,
|
||||||
|
'name' => $request->name,
|
||||||
|
'domain' => $request->domain,
|
||||||
|
'tax_id' => $request->tax_id,
|
||||||
|
'bank_name' => $request->bank_name,
|
||||||
|
'account_holder' => $request->account_holder,
|
||||||
|
'iban' => $request->iban,
|
||||||
|
'business_type_id' => $request->business_type_id,
|
||||||
|
'business_type_name' => BusinessTypeEnum::name($request->business_type_id),
|
||||||
|
'logo' => $logo,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$user->update(['authority_level' => 1]);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function show(UserGateway $gateway): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse($gateway);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(UpdateRequest $request, UserGateway $gateway): JsonResponse
|
||||||
|
{
|
||||||
|
$logo = null;
|
||||||
|
$user = Auth::guard('web')->user();
|
||||||
|
|
||||||
|
if ($request->has('logo'))
|
||||||
|
{
|
||||||
|
FileFacade::delete($gateway->logo, true);
|
||||||
|
$logo = FileFacade::save(request()->file('logo'), "{$user->id}");
|
||||||
|
}
|
||||||
|
|
||||||
|
$gateway->update([
|
||||||
|
'name' => $request->name,
|
||||||
|
'domain' => $request->domain,
|
||||||
|
'business_type_id' => $request->business_type_id,
|
||||||
|
'business_type_name' => BusinessTypeEnum::name($request->business_type_id),
|
||||||
|
'logo' => $logo,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy(UserGateway $gateway): JsonResponse
|
||||||
|
{
|
||||||
|
$gateway->delete();
|
||||||
|
return $this->successResponse();
|
||||||
|
}
|
||||||
|
}
|
||||||
35
backend/app/User/Controllers/Payment/PaymentController.php
Normal file
35
backend/app/User/Controllers/Payment/PaymentController.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controllers\Payment;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Services\Payments\DTO\PaymentCreateDTO;
|
||||||
|
use App\Services\Payments\PaymentService;
|
||||||
|
use App\Traits\ApiResponse;
|
||||||
|
use App\User\Requests\Payment\FIB\StoreRequest;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
|
||||||
|
public $payment_service;
|
||||||
|
|
||||||
|
public function __construct(PaymentService $payment_service)
|
||||||
|
{
|
||||||
|
$this->payment_service = $payment_service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createPayment(StoreRequest $request): JsonResponse
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$dto = PaymentCreateDTO::fromRequest($request);
|
||||||
|
$result = $this->payment_service->createPayment($dto);
|
||||||
|
return $this->successResponse($result);
|
||||||
|
} catch (\Exception $exception) {
|
||||||
|
throw $exception;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,14 +2,19 @@
|
|||||||
|
|
||||||
namespace App\User\Controllers;
|
namespace App\User\Controllers;
|
||||||
|
|
||||||
|
use App\Facades\File\FileFacade;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\City;
|
||||||
|
use App\Models\Province;
|
||||||
use App\Traits\ApiResponse;
|
use App\Traits\ApiResponse;
|
||||||
use App\User\Requests\Profile\ChangePasswordRequest;
|
use App\User\Requests\Profile\ChangePasswordRequest;
|
||||||
use App\User\Requests\Profile\EditRequest;
|
use App\User\Requests\Profile\EditRequest;
|
||||||
use App\User\Resources\UserResource;
|
use App\User\Resources\UserResource;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
use Illuminate\Support\Facades\Hash;
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class ProfileController extends Controller
|
class ProfileController extends Controller
|
||||||
{
|
{
|
||||||
@@ -20,11 +25,40 @@ class ProfileController extends Controller
|
|||||||
return $this->successResponse(new UserResource(Auth::user()));
|
return $this->successResponse(new UserResource(Auth::user()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Throwable
|
||||||
|
*/
|
||||||
public function edit(EditRequest $request): JsonResponse
|
public function edit(EditRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
|
$province = Province::query()->find($request->province_id);
|
||||||
|
$city = City::query()->find($request->city_id);
|
||||||
|
|
||||||
$user->update($request->validated());
|
DB::transaction(function () use ($user, $province, $city, $request) {
|
||||||
|
if ($user->kyc_status == 0)
|
||||||
|
{
|
||||||
|
$user->documents()->create([
|
||||||
|
'title' => 'id_card',
|
||||||
|
'url' => FileFacade::save($request->file('id_card'), "{$user->id}/"),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->update([
|
||||||
|
'first_name' => $request->first_name,
|
||||||
|
'last_name' => $request->last_name,
|
||||||
|
'national_id' => $user->kyc_status == 0 ? $request->national_id : $user->national_id,
|
||||||
|
'address' => $request->address,
|
||||||
|
'postal_code' => $request->postal_code,
|
||||||
|
'phone_number' => $request->phone_number,
|
||||||
|
'province_id' => $province->id,
|
||||||
|
'province_name' => $province->name,
|
||||||
|
'city_id' => $city->id,
|
||||||
|
'city_name' => $city->name,
|
||||||
|
'birth_date' => $request->birth_date,
|
||||||
|
'email' => $request->email,
|
||||||
|
'kyc_status' => 1,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
return $this->successResponse();
|
return $this->successResponse();
|
||||||
}
|
}
|
||||||
|
|||||||
17
backend/app/User/Controllers/ProvinceController.php
Executable file
17
backend/app/User/Controllers/ProvinceController.php
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Controllers;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Province;
|
||||||
|
use App\Traits\ApiResponse;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
|
|
||||||
|
class ProvinceController extends Controller
|
||||||
|
{
|
||||||
|
use ApiResponse;
|
||||||
|
public function list(): JsonResponse
|
||||||
|
{
|
||||||
|
return $this->successResponse(Province::all(['id', 'name']));
|
||||||
|
}
|
||||||
|
}
|
||||||
37
backend/app/User/Requests/Gateway/StoreRequest.php
Normal file
37
backend/app/User/Requests/Gateway/StoreRequest.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Gateway;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class StoreRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return Auth::guard('web')->user()->kyc_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'domain' => 'required|string|max:255',
|
||||||
|
'tax_id' => 'required|string',
|
||||||
|
'bank_name' => 'required|string|max:255',
|
||||||
|
'account_holder' => 'required|string',
|
||||||
|
'iban' => 'required|string|max:255',
|
||||||
|
'logo' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||||
|
'business_type_id' => 'required|string|exists:business_types,id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
33
backend/app/User/Requests/Gateway/UpdateRequest.php
Normal file
33
backend/app/User/Requests/Gateway/UpdateRequest.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Gateway;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class UpdateRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return Auth::guard('web')->user()->kyc_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => 'required|string|max:255',
|
||||||
|
'domain' => 'required|string|max:255',
|
||||||
|
'business_type_id' => 'required|string|exists:business_types,id',
|
||||||
|
'logo' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
36
backend/app/User/Requests/Payment/FIB/StoreRequest.php
Normal file
36
backend/app/User/Requests/Payment/FIB/StoreRequest.php
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\User\Requests\Payment\FIB;
|
||||||
|
|
||||||
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
class StoreRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*/
|
||||||
|
public function authorize(): bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
return Auth::guard('web')->user()->kyc_status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array<string, ValidationRule|array|string>
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'username' => ['required'],
|
||||||
|
'track_id' => ['required'],
|
||||||
|
'amount' => ['required'],
|
||||||
|
'currency' => ['required'],
|
||||||
|
'callback_url' => ['required'],
|
||||||
|
'user_gateway_id' => ['required'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace App\User\Requests\Profile;
|
|||||||
|
|
||||||
use Illuminate\Contracts\Validation\ValidationRule;
|
use Illuminate\Contracts\Validation\ValidationRule;
|
||||||
use Illuminate\Foundation\Http\FormRequest;
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use Illuminate\Validation\Validator;
|
use Illuminate\Validation\Validator;
|
||||||
|
|
||||||
@@ -24,47 +25,20 @@ class EditRequest extends FormRequest
|
|||||||
*/
|
*/
|
||||||
public function rules(): array
|
public function rules(): array
|
||||||
{
|
{
|
||||||
$user = $this->user();
|
$user = Auth::guard('web')->user();
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'first_name' => [
|
'first_name' => 'required|string|max:255',
|
||||||
Rule::prohibitedIf($user->kyc_status == 1), 'string',
|
'last_name' => 'required|string|max:255',
|
||||||
],
|
'national_id' => [Rule::prohibitedIf($user->kyc_status == 1), 'string',],
|
||||||
'last_name' => [
|
'email' => 'required|email|max:255',
|
||||||
Rule::prohibitedIf($user->kyc_status == 1), 'string',
|
'address' => 'required|string',
|
||||||
],
|
'postal_code' => 'required|string',
|
||||||
'national_id' => [
|
'phone_number' => 'required|string',
|
||||||
Rule::prohibitedIf($user->kyc_status == 1), 'string',
|
'province_id' => 'required|exists:provinces,id',
|
||||||
],
|
'city_id' => 'required|exists:cities,id',
|
||||||
'address' => 'required',
|
'birth_date' => 'required|date',
|
||||||
'postal_code' => 'required',
|
'id_card' => [Rule::prohibitedIf($user->kyc_status == 1), 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048']
|
||||||
'phone_number' => 'required',
|
|
||||||
'province_id' => 'required',
|
|
||||||
'city_id' => 'required',
|
|
||||||
];
|
|
||||||
}
|
|
||||||
public function after(): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
function (Validator $validator) {
|
|
||||||
$user = $this->user();
|
|
||||||
if ($user->kyc_status == 1) {
|
|
||||||
$lockedFields = [
|
|
||||||
'first_name',
|
|
||||||
'last_name',
|
|
||||||
'national_id',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($lockedFields as $field) {
|
|
||||||
if ($this->filled($field)) {
|
|
||||||
$validator->errors()->add(
|
|
||||||
$field,
|
|
||||||
'you cannot change this field.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,19 @@ class UserResource extends JsonResource
|
|||||||
'id' => $this->id,
|
'id' => $this->id,
|
||||||
'username' => $this->username,
|
'username' => $this->username,
|
||||||
'email' => $this->email,
|
'email' => $this->email,
|
||||||
|
'first_name' => $this->first_name,
|
||||||
|
'last_name' => $this->last_name,
|
||||||
|
'national_id' => $this->national_id,
|
||||||
|
'address' => $this->address,
|
||||||
|
'postal_code' => $this->postal_code,
|
||||||
|
'phone_number' => $this->phone_number,
|
||||||
|
'province_id' => $this->province_id,
|
||||||
|
'province_name' => $this->province_name,
|
||||||
|
'city_id' => $this->city_id,
|
||||||
|
'city_name' => $this->city_name,
|
||||||
|
'birth_date' => $this->birth_date,
|
||||||
|
'kyc_status' => $this->kyc_status,
|
||||||
|
'authority_level' => $this->authority_level,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Models\Expert;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -127,6 +127,12 @@ return [
|
|||||||
'path' => storage_path('logs/laravel.log'),
|
'path' => storage_path('logs/laravel.log'),
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'fib_authorization' => [
|
||||||
|
'driver' => 'single',
|
||||||
|
'path' => storage_path('logs/fib/authorization.log'),
|
||||||
|
'level' => 'error',
|
||||||
|
],
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
use App\Models\GatewayCategory;
|
use App\Models\BusinessType;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @extends Factory<GatewayCategory>
|
* @extends Factory<BusinessType>
|
||||||
*/
|
*/
|
||||||
class GatewayCategoryFactory extends Factory
|
class BusinessTypeFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
24
backend/database/factories/FibTransactionFactory.php
Normal file
24
backend/database/factories/FibTransactionFactory.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\FibTransaction;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Factory<FibTransaction>
|
||||||
|
*/
|
||||||
|
class FibTransactionFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
24
backend/database/factories/FibTransactionStatusFactory.php
Normal file
24
backend/database/factories/FibTransactionStatusFactory.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\FibTransactionStatus;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Factory<FibTransactionStatus>
|
||||||
|
*/
|
||||||
|
class FibTransactionStatusFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace Database\Factories;
|
namespace Database\Factories;
|
||||||
|
|
||||||
use App\Models\Gateway;
|
use App\Models\Transaction;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @extends Factory<Gateway>
|
* @extends Factory<Transaction>
|
||||||
*/
|
*/
|
||||||
class GatewayFactory extends Factory
|
class TransactionFactory extends Factory
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Define the model's default state.
|
* Define the model's default state.
|
||||||
24
backend/database/factories/UserGatewayFactory.php
Normal file
24
backend/database/factories/UserGatewayFactory.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Factories;
|
||||||
|
|
||||||
|
use App\Models\UserGateway;
|
||||||
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @extends Factory<UserGateway>
|
||||||
|
*/
|
||||||
|
class UserGatewayFactory extends Factory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Define the model's default state.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
public function definition(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,7 +22,6 @@ return new class extends Migration
|
|||||||
$table->string('national_id')->nullable();
|
$table->string('national_id')->nullable();
|
||||||
$table->string('address')->nullable();
|
$table->string('address')->nullable();
|
||||||
$table->string('postal_code')->nullable();
|
$table->string('postal_code')->nullable();
|
||||||
$table->string('tax_id')->nullable();
|
|
||||||
$table->string('phone_number')->nullable();
|
$table->string('phone_number')->nullable();
|
||||||
$table->date('birth_date')->nullable();
|
$table->date('birth_date')->nullable();
|
||||||
$table->foreignId('province_id')->nullable()->constrained('provinces');
|
$table->foreignId('province_id')->nullable()->constrained('provinces');
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::create('gateway_categories', function (Blueprint $table) {
|
Schema::create('business_types', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->string('name');
|
$table->string('name');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
@@ -23,6 +23,6 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('gateway_categories');
|
Schema::dropIfExists('business_types');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -11,7 +11,7 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function up(): void
|
public function up(): void
|
||||||
{
|
{
|
||||||
Schema::create('gateways', function (Blueprint $table) {
|
Schema::create('user_gateways', function (Blueprint $table) {
|
||||||
$table->id();
|
$table->id();
|
||||||
$table->foreignId('user_id')->constrained('users');
|
$table->foreignId('user_id')->constrained('users');
|
||||||
$table->string('username');
|
$table->string('username');
|
||||||
@@ -22,8 +22,8 @@ return new class extends Migration
|
|||||||
$table->string('account_holder');
|
$table->string('account_holder');
|
||||||
$table->string('logo')->nullable();
|
$table->string('logo')->nullable();
|
||||||
$table->string('iban');
|
$table->string('iban');
|
||||||
$table->foreignId('category_id')->constrained('gateway_categories');
|
$table->foreignId('business_type_id')->constrained('business_types');
|
||||||
$table->string('category_name');
|
$table->string('business_type_name');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -33,6 +33,6 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('gateways');
|
Schema::dropIfExists('user_gateways');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -23,7 +23,7 @@ return new class extends Migration
|
|||||||
$table->foreignId('status_id')->constrained('payment_statuses');
|
$table->foreignId('status_id')->constrained('payment_statuses');
|
||||||
$table->string('status_name');
|
$table->string('status_name');
|
||||||
$table->ipAddress('ip');
|
$table->ipAddress('ip');
|
||||||
$table->foreignId('gateway_id')->constrained('gateways');
|
$table->foreignId('user_gateway_id')->constrained('user_gateways');
|
||||||
$table->timestamps();
|
$table->timestamps();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('transactions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained('users');
|
||||||
|
$table->string('amount')->nullable();
|
||||||
|
$table->string('currency')->nullable();
|
||||||
|
$table->string('callback_url')->nullable();
|
||||||
|
$table->string('description')->nullable();
|
||||||
|
$table->dateTime('expires_in')->nullable();
|
||||||
|
$table->foreignId('payment_id')->constrained('payments');
|
||||||
|
$table->string('payment_track_id')->nullable();
|
||||||
|
$table->foreignId('user_gateway_id')->constrained('user_gateways');
|
||||||
|
$table->integer('status')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('transactions');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('fib_transaction_statuses', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('name');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('fib_transaction_statuses');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration {
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('fib_transactions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('transaction_id')->constrained('transactions');
|
||||||
|
$table->text('qrcode')->nullable();
|
||||||
|
$table->string('readable_code')->nullable();
|
||||||
|
$table->string('personalAppLink')->nullable();
|
||||||
|
$table->string('businessAppLink')->nullable();
|
||||||
|
$table->string('corporateAppLink')->nullable();
|
||||||
|
$table->string('paymentId')->nullable();
|
||||||
|
$table->string('paymentMethod')->nullable();
|
||||||
|
$table->timestamp('validUntil')->nullable();
|
||||||
|
$table->foreignId('status_id')->constrained('fib_transaction_statuses');
|
||||||
|
$table->string('status_name')->nullable();
|
||||||
|
$table->timestamp('paidAt')->nullable();
|
||||||
|
$table->string('paidAmount')->nullable();
|
||||||
|
$table->string('paidCurrency')->nullable();
|
||||||
|
$table->string('decliningReason')->nullable();
|
||||||
|
$table->timestamp('declinedAt')->nullable();
|
||||||
|
$table->string('paidByName')->nullable();
|
||||||
|
$table->string('paidByIban')->nullable();
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('fib_transactions');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('password_reset_otps', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->string('email')->index();
|
||||||
|
$table->string('otp');
|
||||||
|
$table->string('guard_name');
|
||||||
|
$table->timestamp('expires_at');
|
||||||
|
$table->timestamp('verified_at')->nullable();
|
||||||
|
$table->unsignedTinyInteger('attempts')->default(0);
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('password_reset_otps');
|
||||||
|
}
|
||||||
|
};
|
||||||
34
backend/database/seeders/BusinessTypeSeeder.php
Normal file
34
backend/database/seeders/BusinessTypeSeeder.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class BusinessTypeSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
DB::table('business_types')->insert([
|
||||||
|
['id' => 1, 'name' => 'medical', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 2, 'name' => 'legal', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 3, 'name' => 'engineering', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 4, 'name' => 'education', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 5, 'name' => 'consulting', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 6, 'name' => 'beauty', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 7, 'name' => 'technical_services', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 8, 'name' => 'financial', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 9, 'name' => 'real_estate', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 10, 'name' => 'restaurant', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 11, 'name' => 'shop', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 12, 'name' => 'transportation', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 13, 'name' => 'art', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 14, 'name' => 'sport', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 15, 'name' => 'other', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace Database\Seeders;
|
|||||||
|
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class CitySeeder extends Seeder
|
class CitySeeder extends Seeder
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,125 @@ class CitySeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
//
|
DB::table('cities')->insert([
|
||||||
|
// Baghdad
|
||||||
|
['province_id' => 1, 'name' => 'Baghdad', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 1, 'name' => 'Sadr City', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 1, 'name' => 'Kadhimiya', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 1, 'name' => 'Adhamiyah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 1, 'name' => 'Abu Ghraib', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 1, 'name' => 'Mahmudiya', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Basra
|
||||||
|
['province_id' => 2, 'name' => 'Basra', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 2, 'name' => 'Al-Zubair', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 2, 'name' => 'Umm Qasr', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 2, 'name' => 'Al-Qurnah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 2, 'name' => 'Shatt Al-Arab', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 2, 'name' => 'Abu Al-Khaseeb', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Nineveh
|
||||||
|
['province_id' => 3, 'name' => 'Mosul', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 3, 'name' => 'Tal Afar', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 3, 'name' => 'Sinjar', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 3, 'name' => 'Al-Hamdaniya', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 3, 'name' => 'Bashiqa', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 3, 'name' => 'Qayyarah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Erbil
|
||||||
|
['province_id' => 4, 'name' => 'Erbil', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 4, 'name' => 'Shaqlawa', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 4, 'name' => 'Soran', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 4, 'name' => 'Koya', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 4, 'name' => 'Makhmur', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Sulaymaniyah
|
||||||
|
['province_id' => 5, 'name' => 'Sulaymaniyah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 5, 'name' => 'Halabja', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 5, 'name' => 'Ranya', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 5, 'name' => 'Kalar', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 5, 'name' => 'Chamchamal', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Duhok
|
||||||
|
['province_id' => 6, 'name' => 'Duhok', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 6, 'name' => 'Zakho', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 6, 'name' => 'Amedi', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 6, 'name' => 'Akre', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 6, 'name' => 'Semel', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Kirkuk
|
||||||
|
['province_id' => 7, 'name' => 'Kirkuk', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 7, 'name' => 'Hawija', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 7, 'name' => 'Dibis', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 7, 'name' => 'Daquq', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Diyala
|
||||||
|
['province_id' => 8, 'name' => 'Baqubah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 8, 'name' => 'Khanaqin', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 8, 'name' => 'Muqdadiyah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 8, 'name' => 'Balad Ruz', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 8, 'name' => 'Jalawla', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Anbar
|
||||||
|
['province_id' => 9, 'name' => 'Ramadi', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 9, 'name' => 'Fallujah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 9, 'name' => 'Haditha', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 9, 'name' => 'Hit', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 9, 'name' => 'Al-Qaim', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 9, 'name' => 'Rutba', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Salah al-Din
|
||||||
|
['province_id' => 10, 'name' => 'Tikrit', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 10, 'name' => 'Samarra', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 10, 'name' => 'Balad', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 10, 'name' => 'Baiji', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 10, 'name' => 'Tuz Khurmatu', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Karbala
|
||||||
|
['province_id' => 11, 'name' => 'Karbala', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 11, 'name' => 'Al-Hindiya', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 11, 'name' => 'Ain Al-Tamur', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Najaf
|
||||||
|
['province_id' => 12, 'name' => 'Najaf', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 12, 'name' => 'Kufa', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 12, 'name' => 'Al-Manathera', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Babil
|
||||||
|
['province_id' => 13, 'name' => 'Hillah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 13, 'name' => 'Al-Mahawil', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 13, 'name' => 'Al-Musayyib', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 13, 'name' => 'Hashimiya', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Wasit
|
||||||
|
['province_id' => 14, 'name' => 'Kut', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 14, 'name' => 'Al-Hayy', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 14, 'name' => 'Al-Numaniyah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 14, 'name' => 'Badra', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Maysan
|
||||||
|
['province_id' => 15, 'name' => 'Amarah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 15, 'name' => 'Ali Al-Sharqi', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 15, 'name' => 'Al-Majarr Al-Kabir', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 15, 'name' => 'Qalat Saleh', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Dhi Qar
|
||||||
|
['province_id' => 16, 'name' => 'Nasiriyah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 16, 'name' => 'Al-Shatrah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 16, 'name' => 'Suq Al-Shuyukh', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 16, 'name' => 'Rifai', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Muthanna
|
||||||
|
['province_id' => 17, 'name' => 'Samawah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 17, 'name' => 'Rumaitha', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 17, 'name' => 'Al-Khidhir', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 17, 'name' => 'Salman', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
|
||||||
|
// Al-Qadisiyyah
|
||||||
|
['province_id' => 18, 'name' => 'Diwaniyah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 18, 'name' => 'Afak', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 18, 'name' => 'Al-Shamiya', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['province_id' => 18, 'name' => 'Hamza', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,5 +22,9 @@ class DatabaseSeeder extends Seeder
|
|||||||
'email' => 'test@example.com',
|
'email' => 'test@example.com',
|
||||||
'password' => 'password123@',
|
'password' => 'password123@',
|
||||||
]);
|
]);
|
||||||
|
$this->call([
|
||||||
|
ProvinceSeeder::class,
|
||||||
|
CitySeeder::class,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Database\Seeders;
|
|||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class GatewayCategorySeeder extends Seeder
|
class FibTransactionSeeder extends Seeder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
24
backend/database/seeders/FibTransactionStatusSeeder.php
Normal file
24
backend/database/seeders/FibTransactionStatusSeeder.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
|
class FibTransactionStatusSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
DB::table('fib_transaction_statuses')->insert([
|
||||||
|
['id' => 0, 'name' => 'unpaid', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
['id' => 1, 'name' => 'cancelled', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
['id' => 2, 'name' => 'expired', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
['id' => 3, 'name' => 'paid', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
['id' => 4, 'name' => 'refunded', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ namespace Database\Seeders;
|
|||||||
|
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class PaymentStatusSeeder extends Seeder
|
class PaymentStatusSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,12 @@ class PaymentStatusSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
//
|
DB::table('payment_statuses')->insert([
|
||||||
|
['id' => 0, 'name' => 'unpaid', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
['id' => 1, 'name' => 'cancelled', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
['id' => 2, 'name' => 'expired', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
['id' => 3, 'name' => 'paid', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
['id' => 4, 'name' => 'refunded', 'created_at' => now(), 'updated_at' => now(),],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace Database\Seeders;
|
|||||||
|
|
||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
|
||||||
class ProvinceSeeder extends Seeder
|
class ProvinceSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@@ -12,6 +13,25 @@ class ProvinceSeeder extends Seeder
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
//
|
DB::table('provinces')->insert([
|
||||||
|
['id' => 1, 'name' => 'Baghdad', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 2, 'name' => 'Basra', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 3, 'name' => 'Nineveh', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 4, 'name' => 'Erbil', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 5, 'name' => 'Sulaymaniyah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 6, 'name' => 'Duhok', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 7, 'name' => 'Kirkuk', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 8, 'name' => 'Diyala', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 9, 'name' => 'Anbar', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 10, 'name' => 'Salah al-Din', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 11, 'name' => 'Karbala', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 12, 'name' => 'Najaf', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 13, 'name' => 'Babil', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 14, 'name' => 'Wasit', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 15, 'name' => 'Maysan', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 16, 'name' => 'Dhi Qar', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 17, 'name' => 'Muthanna', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
['id' => 18, 'name' => 'Al-Qadisiyyah', 'created_at' => now(), 'updated_at' => now()],
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Database\Seeders;
|
|||||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
class GatewaySeeder extends Seeder
|
class TransactionSeeder extends Seeder
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
17
backend/database/seeders/UserGatewaySeeder.php
Normal file
17
backend/database/seeders/UserGatewaySeeder.php
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
|
||||||
|
class UserGatewaySeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
use \App\User\Controllers\Payment\PaymentController;
|
||||||
|
|
||||||
Route::get('/user', function (Request $request) {
|
Route::get('/user', function (Request $request) {
|
||||||
return $request->user();
|
return $request->user();
|
||||||
})->middleware('auth:api');
|
})->middleware('auth:api');
|
||||||
|
|
||||||
|
Route::prefix('v1')->group(function () {
|
||||||
|
Route::prefix('payment')
|
||||||
|
// ->middleware('auth:api')
|
||||||
|
->group(function () {
|
||||||
|
Route::post('/create_payment', [PaymentController::class, 'createPayment'])->name('create_payment');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ Route::prefix('auth')
|
|||||||
->name('auth.')
|
->name('auth.')
|
||||||
->controller(AuthController::class)
|
->controller(AuthController::class)
|
||||||
->group(function () {
|
->group(function () {
|
||||||
Route::post('register', 'register')->name('register');
|
|
||||||
Route::post('login', 'login')->name('login');
|
Route::post('login', 'login')->name('login');
|
||||||
Route::post('logout', 'logout')->name('logout');
|
Route::post('logout', 'logout')->name('logout');
|
||||||
});
|
});
|
||||||
@@ -39,6 +38,7 @@ Route::prefix('user_management')
|
|||||||
Route::post('/{user}', 'update')->name('update');
|
Route::post('/{user}', 'update')->name('update');
|
||||||
Route::delete('/{user}', 'destroy')->name('destroy');
|
Route::delete('/{user}', 'destroy')->name('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('roles')
|
Route::prefix('roles')
|
||||||
->name('roles.')
|
->name('roles.')
|
||||||
->middleware(['auth:expert', 'permission:role-management'])
|
->middleware(['auth:expert', 'permission:role-management'])
|
||||||
@@ -50,6 +50,7 @@ Route::prefix('roles')
|
|||||||
Route::post('/{role}', 'update')->name('update');
|
Route::post('/{role}', 'update')->name('update');
|
||||||
Route::delete('/{role}', 'destroy')->name('destroy');
|
Route::delete('/{role}', 'destroy')->name('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('permissions')
|
Route::prefix('permissions')
|
||||||
->name('permissions.')
|
->name('permissions.')
|
||||||
->middleware(['auth:expert', 'permission:permission-management'])
|
->middleware(['auth:expert', 'permission:permission-management'])
|
||||||
@@ -61,6 +62,7 @@ Route::prefix('permissions')
|
|||||||
Route::post('/{permission}', 'update')->name('update');
|
Route::post('/{permission}', 'update')->name('update');
|
||||||
Route::delete('/{permission}', 'destroy')->name('destroy');
|
Route::delete('/{permission}', 'destroy')->name('destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::prefix('expert')
|
Route::prefix('expert')
|
||||||
->name('expert.')
|
->name('expert.')
|
||||||
->middleware(['auth:expert', 'permission:expert-management'])
|
->middleware(['auth:expert', 'permission:expert-management'])
|
||||||
|
|||||||
@@ -5,7 +5,10 @@ use App\Admin\Controllers\PermissionManagementController;
|
|||||||
use App\Admin\Controllers\RoleManagementController;
|
use App\Admin\Controllers\RoleManagementController;
|
||||||
use App\Admin\Controllers\UserManagementController;
|
use App\Admin\Controllers\UserManagementController;
|
||||||
use App\User\Controllers\AuthController;
|
use App\User\Controllers\AuthController;
|
||||||
|
use App\User\Controllers\GatewayManagementController;
|
||||||
|
use App\User\Controllers\CityController;
|
||||||
use App\User\Controllers\ProfileController;
|
use App\User\Controllers\ProfileController;
|
||||||
|
use App\User\Controllers\ProvinceController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::prefix('auth')
|
Route::prefix('auth')
|
||||||
@@ -26,3 +29,29 @@ Route::prefix('profile')
|
|||||||
Route::post('edit', 'edit')->name('edit');
|
Route::post('edit', 'edit')->name('edit');
|
||||||
Route::post('change_password', 'changePassword')->name('changePassword');
|
Route::post('change_password', 'changePassword')->name('changePassword');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::prefix('user_gateway')
|
||||||
|
->name('userGateway.')
|
||||||
|
->middleware(['auth'])
|
||||||
|
->controller(GatewayManagementController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('/', 'index')->name('index');
|
||||||
|
Route::post('/', 'store')->name('store');
|
||||||
|
Route::get('/{gateway}', 'show')->name('show');
|
||||||
|
Route::post('/{gateway}', 'update')->name('update');
|
||||||
|
Route::delete('/{gateway}', 'destroy')->name('destroy');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('province')
|
||||||
|
->name('province.')
|
||||||
|
->controller(ProvinceController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('list', 'list')->name('list');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::prefix('city')
|
||||||
|
->name('city.')
|
||||||
|
->controller(CityController::class)
|
||||||
|
->group(function () {
|
||||||
|
Route::get('list', 'list')->name('list');
|
||||||
|
});
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ services:
|
|||||||
- payment
|
- payment
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
build:
|
image: payment-backend:latest
|
||||||
context: ${BACKEND_PATH}
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
container_name: laravel
|
container_name: laravel
|
||||||
tty: true
|
tty: true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -54,6 +52,8 @@ services:
|
|||||||
- postgres
|
- postgres
|
||||||
networks:
|
networks:
|
||||||
- payment
|
- payment
|
||||||
|
command: ["php", "artisan", "serve", "--host=0.0.0.0", "--port=9000"]
|
||||||
|
# Prints "Overridden command!"
|
||||||
# logging:
|
# logging:
|
||||||
# driver: "syslog"
|
# driver: "syslog"
|
||||||
# options:
|
# options:
|
||||||
|
|||||||
Reference in New Issue
Block a user