diff --git a/.gitignore b/.gitignore index 3bf780b6..c31b3a14 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea -.env \ No newline at end of file +.env +front \ No newline at end of file diff --git a/backend/.dockerignore b/backend/.dockerignore old mode 100644 new mode 100755 diff --git a/backend/.editorconfig b/backend/.editorconfig old mode 100644 new mode 100755 diff --git a/backend/.env.example b/backend/.env.example old mode 100644 new mode 100755 index 409384df..cff0c7b8 --- a/backend/.env.example +++ b/backend/.env.example @@ -63,3 +63,15 @@ AWS_BUCKET= AWS_USE_PATH_STYLE_ENDPOINT=false VITE_APP_NAME="${APP_NAME}" + +FIB_AUTHORIZATION_URL= +FIB_CLIENT_ID= +FIB_CLIENT_SECRET= + +FIB_CREATE_PAYMENT_URL + +FIB_CHECK_PAYMENT_STATUS_URL + +FIB_CANCEL_PAYMENT_URL + +FIB_REFUND_URL diff --git a/backend/.gitattributes b/backend/.gitattributes old mode 100644 new mode 100755 diff --git a/backend/.gitignore b/backend/.gitignore old mode 100644 new mode 100755 diff --git a/backend/.npmrc b/backend/.npmrc old mode 100644 new mode 100755 diff --git a/backend/Dockerfile b/backend/Dockerfile old mode 100644 new mode 100755 index c1d77b0f..6b930093 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,28 +1,35 @@ -FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie +FROM php:8.5.3-fpm-alpine3.23 -RUN apt-get update \ - && apt-get install -y --no-install-recommends libpq-dev \ +# Install common PHP extension dependencies +RUN apk update && apk add --no-cache \ + bash \ + curl \ + libpng \ + libpng-dev \ + libjpeg-turbo-dev \ + freetype-dev \ + libwebp-dev \ + libxml2-dev \ unzip \ - zip \ - && install-php-extensions pdo_pgsql pgsql \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* + libzip-dev \ + libpq-dev \ + && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \ + && docker-php-ext-install pdo_pgsql gd zip +# Set the working directory WORKDIR /var/www/payment -#ENV SERVER_NAME=your-domain-name.example.com - -# Copy Laravel application COPY . . -# Give permissions to storage and bootstrap/cache -RUN chmod -R 777 storage bootstrap/cache +RUN chmod -R 775 /var/www/payment/storage /var/www/payment/bootstrap/cache # Install Composer -COPY --from=docker.arvancloud.ir/composer:latest /usr/bin/composer /usr/bin/composer +COPY --from=composer:latest /usr/bin/composer /usr/bin/composer +ENV COMPOSER_ALLOW_SUPERUSER=1 -CMD composer install;\ - php artisan key:generate;\ - php artisan migrate;\ - php artisan db:seed;\ - frankenphp php-server -r public/ +# Default command +CMD composer install ;\ + composer dump-autoload --optimize --classmap-authoritative ;\ + php artisan migrate ;\ + php artisan db:seed ;\ + php-fpm diff --git a/backend/Dockerfile.production b/backend/Dockerfile.production old mode 100644 new mode 100755 index 848908b5..e2a7d0cf --- a/backend/Dockerfile.production +++ b/backend/Dockerfile.production @@ -14,19 +14,28 @@ COPY . . RUN composer dump-autoload --optimize --classmap-authoritative -FROM docker.arvancloud.ir/dunglas/frankenphp:1.11.2-php8.5-trixie AS application +FROM php:8.5.3-fpm-alpine3.23 AS application -RUN apt-get update \ - && apt-get install -y --no-install-recommends libpq-dev unzip zip \ - && install-php-extensions pdo_pgsql pgsql \ - && apt-get clean \ - && rm -rf /var/lib/apt/lists/* +RUN apk update && apk add --no-cache \ + bash \ + curl \ + libpng \ + libpng-dev \ + libjpeg-turbo-dev \ + freetype-dev \ + libwebp-dev \ + libxml2-dev \ + unzip \ + libzip-dev \ + libpq-dev \ + && docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp \ + && docker-php-ext-install pdo_pgsql gd zip WORKDIR /var/www/payment COPY --from=builder /app /var/www/payment RUN chown -R www-data:www-data /var/www/payment \ - && chmod -R 775 storage bootstrap/cache + && chmod -R 665 storage bootstrap/cache -CMD ["frankenphp", "php-server", "-r", "public/"] +CMD ["php-fpm"] diff --git a/backend/README.md b/backend/README.md old mode 100644 new mode 100755 diff --git a/backend/app/Admin/Controllers/AuthController.php b/backend/app/Admin/Controllers/AuthController.php new file mode 100755 index 00000000..9bd88920 --- /dev/null +++ b/backend/app/Admin/Controllers/AuthController.php @@ -0,0 +1,48 @@ + $request->password]; + + if (filter_var($request->login, FILTER_VALIDATE_EMAIL)) { + $credentials['email'] = $request->login; + } else { + $credentials['username'] = $request->login; + } + + if (Auth::guard('expert')->attempt($credentials)) { + $request->session()->regenerate(); + + return $this->successResponse(); + } + + return $this->errorResponse(__('messages.incorrect_or_username_password')); + } + + public function logout(Request $request): JsonResponse + { + Auth::guard('expert')->logout(); + + $request->session()->invalidate(); + + $request->session()->regenerateToken(); + + return $this->successResponse(); + } +} diff --git a/backend/app/Admin/Controllers/DocumentationController.php b/backend/app/Admin/Controllers/DocumentationController.php new file mode 100755 index 00000000..54e374e5 --- /dev/null +++ b/backend/app/Admin/Controllers/DocumentationController.php @@ -0,0 +1,55 @@ +successResponse($user->load('documents')); + } + + public function confirm(User $user): JsonResponse + { + $user->update([ + 'authority_level' => 1 + ]); + + return $this->successResponse(); + } + + public function reject(RejectRequest $request, User $user): JsonResponse + { + $user->update([ + 'kyc_status' => 0, + 'kyc_reject_reason' => $request->kyc_reject_reason + ]); + + return $this->successResponse(); + } +} diff --git a/backend/app/Admin/Controllers/ExpertManagementController.php b/backend/app/Admin/Controllers/ExpertManagementController.php new file mode 100755 index 00000000..f0edad53 --- /dev/null +++ b/backend/app/Admin/Controllers/ExpertManagementController.php @@ -0,0 +1,112 @@ +json($data); + } + + /** + * Store a newly created resource in storage. + */ + public function store(StoreRequest $request): JsonResponse + { + $province = Province::query()->find($request->province_id); + $city = City::query()->find($request->city_id); + + Expert::query()->create([ + 'username' => $request->username, + 'first_name' => $request->first_name, + 'last_name' => $request->last_name, + 'national_id' => $request->national_id, + 'password' => Hash::make($request->password), + 'email' => $request->email, + 'phone_number' => $request->phone_number, + 'province_id' => $request->province_id, + 'province_name' => $province->name, + 'city_id' => $request->city_id, + 'city_name' => $city->name, + ]); + + return $this->successResponse(); + } + + /** + * Display the specified resource. + */ + public function show(Expert $expert): JsonResponse + { + return $this->successResponse($expert->load(['roles','permissions']) + ); + } + + /** + * Update the specified resource in storage. + */ + public function update(UpdateRequest $request, Expert $expert): JsonResponse + { + $province = Province::query()->find($request->province_id); + $city = City::query()->find($request->city_id); + + $expert->update([ + 'username' => $request->username, + 'first_name' => $request->first_name, + 'last_name' => $request->last_name, + 'national_id' => $request->national_id, + 'password' => Hash::make($request->password), + 'email' => $request->email, + 'phone_number' => $request->phone_number, + 'province_id' => $request->province_id, + 'province_name' => $province->name, + 'city_id' => $request->city_id, + 'city_name' => $city->name, + ]); + + return $this->successResponse(); + } + + /** + * Remove the specified resource from storage. + * @throws Throwable + */ + public function destroy(Expert $expert): JsonResponse + { + DB::transaction(function () use ($expert) { + $expert->roles()->detach(); + $expert->permissions()->detach(); + $expert->delete(); + }); + + return $this->successResponse(); + } +} diff --git a/backend/app/Admin/Controllers/ForgotPasswordOtpController.php b/backend/app/Admin/Controllers/ForgotPasswordOtpController.php new file mode 100644 index 00000000..cdd62a45 --- /dev/null +++ b/backend/app/Admin/Controllers/ForgotPasswordOtpController.php @@ -0,0 +1,89 @@ +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.', + ]); + } +} diff --git a/backend/app/Admin/Controllers/PermissionManagementController.php b/backend/app/Admin/Controllers/PermissionManagementController.php new file mode 100755 index 00000000..10462a70 --- /dev/null +++ b/backend/app/Admin/Controllers/PermissionManagementController.php @@ -0,0 +1,78 @@ +json( + DataTableFacade::run( + Permission::query(), + $request, + allowedFilters: ['*'], + allowedSortings: ['*'] + ) + ); + } + + /** + * Store a newly created resource in storage. + */ + public function store(StoreRequest $request): JsonResponse + { + Permission::create([ + 'name' => $request->name, + 'guard_name' => 'web', + ]); + + return $this->successResponse(); + } + + /** + * Display the specified resource. + */ + public function show(Permission $permission): JsonResponse + { + return $this->successResponse($permission); + } + + /** + * Update the specified resource in storage. + */ + public function update(UpdateRequest $request, Permission $permission): JsonResponse + { + $permission->update([ + 'name' => $request->name, + ]); + + return $this->successResponse(); + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(Permission $permission): JsonResponse + { + $permission->delete(); + + return $this->successResponse(); + } +} diff --git a/backend/app/Admin/Controllers/ProfileController.php b/backend/app/Admin/Controllers/ProfileController.php new file mode 100755 index 00000000..23a80f7e --- /dev/null +++ b/backend/app/Admin/Controllers/ProfileController.php @@ -0,0 +1,56 @@ +successResponse(new ExpertResource(Auth::guard('expert')->user())); + } + + public function edit(EditRequest $request): JsonResponse + { + $expert = $request->user('expert'); + + $expert->update([ + 'username' => $request->username, + 'first_name' => $request->first_name, + 'last_name' => $request->last_name, + 'email' => $expert->email, + 'national_id' => $request->national_id, + 'phone_number' => $request->phone_number, + 'province_id' => $request->province_id, + 'city_id' => $request->city_id, + ]); + + return $this->successResponse(); + } + + public function changePassword(ChangePasswordRequest $request): JsonResponse + { + $expert = Auth::guard('expert')->user(); + + if (! Hash::check($request->current_password, $expert->password)) + { + return $this->errorResponse(__('messages.incorrect_current_password')); + } + + $expert->update([ + 'password' => Hash::make($request->new_password) + ]); + + return $this->successResponse(); + } +} diff --git a/backend/app/Admin/Controllers/RoleManagementController.php b/backend/app/Admin/Controllers/RoleManagementController.php new file mode 100755 index 00000000..c1dc1004 --- /dev/null +++ b/backend/app/Admin/Controllers/RoleManagementController.php @@ -0,0 +1,77 @@ +json($data); + } + + /** + * @throws Throwable + */ + public function store(StoreRequest $request): JsonResponse + { + DB::transaction(function () use ($request) { + $role = Role::create([ + 'name' => $request->name, + 'guard_name' => 'web', + ]); + + $role->givePermissionTo($request->permissions); + }); + + return $this->successResponse(); + } + + /** + * @throws Throwable + */ + public function update(UpdateRequest $request, Role $role): JsonResponse + { + DB::transaction(function () use ($request, $role) { + $role->update([ + 'name' => $request->name, + 'guard_name' => 'web', + ]); + + $role->syncPermissions($request->permissions); + }); + + return $this->successResponse(); + } + + public function show(Role $role): JsonResponse + { + return $this->successResponse($role); + } + + public function destroy(Role $role): JsonResponse + { + $role->delete(); + return $this->successResponse(); + } +} diff --git a/backend/app/Admin/Controllers/UserManagementController.php b/backend/app/Admin/Controllers/UserManagementController.php new file mode 100755 index 00000000..63e96da7 --- /dev/null +++ b/backend/app/Admin/Controllers/UserManagementController.php @@ -0,0 +1,113 @@ +json($data); + } + + /** + * Store a newly created resource in storage. + */ + public function store(StoreRequest $request): JsonResponse + { + $province = Province::query()->find($request->province_id); + $city = City::query()->find($request->city_id); + + User::query()->create([ + 'username' => $request->username, + 'first_name' => $request->first_name, + 'last_name' => $request->last_name, + 'national_id' => $request->national_id, + 'password' => Hash::make($request->password), + 'email' => $request->email, + 'birth_date' => $request->birth_date, + 'phone_number' => $request->phone_number, + 'postal_code' => $request->postal_code, + 'address' => $request->address, + 'province_id' => $request->province_id, + 'province_name' => $province->name, + 'city_id' => $request->city_id, + 'city_name' => $city->name, + ]); + + return $this->successResponse(); + } + + + /** + * Display the specified resource. + */ + public function show(User $user): JsonResponse + { + return $this->successResponse($user); + + } + + /** + * Update the specified resource in storage. + */ + public function update(UpdateRequest $request, User $user): JsonResponse + { + $province = Province::query()->find($request->province_id); + $city = City::query()->find($request->city_id); + + $user->update([ + 'first_name' => $request->first_name, + 'username' => $request->username, + 'last_name' => $request->last_name, + 'national_id' => $request->national_id, + 'password' => Hash::make($request->password), + 'email' => $request->email, + 'birth_date' => $request->birth_date, + 'phone_number' => $request->phone_number, + 'postal_code' => $request->postal_code, + 'address' => $request->address, + 'province_id' => $request->province_id, + 'province_name' => $province->name, + 'city_id' => $request->city_id, + 'city_name' => $city->name, + ]); + + return $this->successResponse(); + } + + /** + * Remove the specified resource from storage. + * @throws Throwable + */ + public function destroy(User $user): JsonResponse + { + $user->delete(); + + return $this->successResponse(); + } +} diff --git a/backend/app/Admin/Requests/Auth/LoginRequest.php b/backend/app/Admin/Requests/Auth/LoginRequest.php new file mode 100755 index 00000000..16c27d74 --- /dev/null +++ b/backend/app/Admin/Requests/Auth/LoginRequest.php @@ -0,0 +1,30 @@ + + */ + public function rules(): array + { + return [ + 'login' => 'required|string', + 'password' => 'required|string', + ]; + } +} diff --git a/backend/app/Admin/Requests/Auth/RegisterRequest.php b/backend/app/Admin/Requests/Auth/RegisterRequest.php new file mode 100755 index 00000000..be5ffa9a --- /dev/null +++ b/backend/app/Admin/Requests/Auth/RegisterRequest.php @@ -0,0 +1,31 @@ + + */ + public function rules(): array + { + return [ + 'username' => 'required|unique:experts,username', + 'email' => 'required|email|unique:experts,email', + 'password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6|confirmed', + ]; + } +} diff --git a/backend/app/Admin/Requests/Documentation/RejectRequest.php b/backend/app/Admin/Requests/Documentation/RejectRequest.php new file mode 100755 index 00000000..0a65ebdf --- /dev/null +++ b/backend/app/Admin/Requests/Documentation/RejectRequest.php @@ -0,0 +1,29 @@ + + */ + public function rules(): array + { + return [ + 'kyc_reject_reason' => 'required|string', + ]; + } +} diff --git a/backend/app/Admin/Requests/ExpertManagement/StoreRequest.php b/backend/app/Admin/Requests/ExpertManagement/StoreRequest.php new file mode 100755 index 00000000..3a866cfe --- /dev/null +++ b/backend/app/Admin/Requests/ExpertManagement/StoreRequest.php @@ -0,0 +1,37 @@ + + */ + public function rules(): array + { + return [ + 'username' => 'required|string|max:255|unique:experts,username', + 'first_name' => 'required|string|max:255', + 'last_name' => 'required|string|max:255', + 'national_id' => 'required|string|max:20|unique:experts,national_id', + 'password' => 'required|string|min:8|confirmed', + 'email' => 'required|email|max:255|unique:experts,email', + 'phone_number' => 'required|string|max:20|unique:experts,phone_number', + 'province_id' => 'required|integer|exists:provinces,id', + 'city_id' => 'required|integer|exists:cities,id', + ]; + } +} diff --git a/backend/app/Admin/Requests/ExpertManagement/UpdateRequest.php b/backend/app/Admin/Requests/ExpertManagement/UpdateRequest.php new file mode 100755 index 00000000..f496445b --- /dev/null +++ b/backend/app/Admin/Requests/ExpertManagement/UpdateRequest.php @@ -0,0 +1,45 @@ + + */ + public function rules(): array + { + return [ + 'username' => ['string', 'max:255', + Rule::unique('experts', 'username')->ignore($this->expert->id),], + 'first_name' => 'string|max:255', + 'last_name' => 'string|max:255', + 'national_id' => ['string', 'max:20', + Rule::unique('experts', 'national_id')->ignore($this->expert->id),], + 'password' => 'string|min:8|confirmed', + 'email' => ['email', 'max:255', + Rule::unique('experts', 'email')->ignore($this->expert->id),], + 'phone_number' => ['string', 'max:20', + Rule::unique('experts', 'phone_number')->ignore($this->expert->id),], + 'province_id' => 'required|integer|exists:provinces,id', + 'city_id' => 'required|integer|exists:cities,id', + ]; + } +} diff --git a/backend/app/Admin/Requests/PermissionManagement/StoreRequest.php b/backend/app/Admin/Requests/PermissionManagement/StoreRequest.php new file mode 100755 index 00000000..7f91eda7 --- /dev/null +++ b/backend/app/Admin/Requests/PermissionManagement/StoreRequest.php @@ -0,0 +1,29 @@ + + */ + public function rules(): array + { + return [ + 'name' => 'required|string|unique:permissions,name', + ]; + } +} diff --git a/backend/app/Admin/Requests/PermissionManagement/UpdateRequest.php b/backend/app/Admin/Requests/PermissionManagement/UpdateRequest.php new file mode 100755 index 00000000..9bcdf8b3 --- /dev/null +++ b/backend/app/Admin/Requests/PermissionManagement/UpdateRequest.php @@ -0,0 +1,33 @@ + + */ + public function rules(): array + { + return [ + 'name' => ['required', 'string', 'max:255', Rule::unique('permissions', 'name')->ignore($this->permission->id)], + ]; + } +} diff --git a/backend/app/Admin/Requests/Profile/ChangePasswordRequest.php b/backend/app/Admin/Requests/Profile/ChangePasswordRequest.php new file mode 100755 index 00000000..f4f0953e --- /dev/null +++ b/backend/app/Admin/Requests/Profile/ChangePasswordRequest.php @@ -0,0 +1,30 @@ + + */ + public function rules(): array + { + return [ + 'current_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:8', + 'new_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:8', + ]; + } +} diff --git a/backend/app/Admin/Requests/Profile/EditRequest.php b/backend/app/Admin/Requests/Profile/EditRequest.php new file mode 100755 index 00000000..6b997c9e --- /dev/null +++ b/backend/app/Admin/Requests/Profile/EditRequest.php @@ -0,0 +1,38 @@ + + */ + public function rules(): array + { + return [ + 'username' => 'string|max:255', + 'first_name' => 'required|string', + 'last_name' => 'required|string', + 'national_id' => 'required', + 'email' => 'string|email|max:255', + 'phone_number' => 'string', + 'province_id' => 'string', + 'city_id' => 'string', + ]; + } +} diff --git a/backend/app/Admin/Requests/RoleManagement/StoreRequest.php b/backend/app/Admin/Requests/RoleManagement/StoreRequest.php new file mode 100755 index 00000000..6318879c --- /dev/null +++ b/backend/app/Admin/Requests/RoleManagement/StoreRequest.php @@ -0,0 +1,31 @@ + + */ + public function rules(): array + { + return [ + 'name' => 'required|string|unique:roles,name', + 'permissions' => 'array', + 'permissions.*' => 'integer|exists:permissions,id', + ]; + } +} diff --git a/backend/app/Admin/Requests/RoleManagement/UpdateRequest.php b/backend/app/Admin/Requests/RoleManagement/UpdateRequest.php new file mode 100755 index 00000000..5b0058c2 --- /dev/null +++ b/backend/app/Admin/Requests/RoleManagement/UpdateRequest.php @@ -0,0 +1,35 @@ + + */ + public function rules(): array + { + return [ + 'name' => ['string', 'max:255', Rule::unique('roles', 'name')->ignore($this->role->id)], + 'permissions' => 'array', + 'permissions.*' => 'integer|exists:permissions,id', + ]; + } +} diff --git a/backend/app/Admin/Requests/UserManagement/StoreRequest.php b/backend/app/Admin/Requests/UserManagement/StoreRequest.php new file mode 100755 index 00000000..38208575 --- /dev/null +++ b/backend/app/Admin/Requests/UserManagement/StoreRequest.php @@ -0,0 +1,40 @@ + + */ + public function rules(): array + { + return [ + 'username' => 'required|string|max:255|unique:users,username', + 'first_name' => 'required|string|max:255', + 'last_name' => 'required|string|max:255', + 'national_id' => 'required|string|max:20|unique:users,national_id', + 'password' => 'required|string|min:6|confirmed', + 'email' => 'required|email|max:255|unique:users,email', + 'birth_date' => 'nullable|date', + 'phone_number' => 'required|string|max:20|unique:users,phone_number', + 'postal_code' => 'nullable|string|max:20', + 'address' => 'nullable|string|max:1000', + 'province_id' => 'required|integer|exists:provinces,id', + 'city_id' => 'required|integer|exists:cities,id', + ]; + } +} diff --git a/backend/app/Admin/Requests/UserManagement/UpdateRequest.php b/backend/app/Admin/Requests/UserManagement/UpdateRequest.php new file mode 100755 index 00000000..99c7af70 --- /dev/null +++ b/backend/app/Admin/Requests/UserManagement/UpdateRequest.php @@ -0,0 +1,49 @@ + + */ + public function rules(): array + { + + return [ + 'username' => ['string', 'max:255', + Rule::unique('users', 'username')->ignore($this->user->id),], + 'first_name' => 'string|max:255', + 'last_name' => 'string|max:255', + 'national_id' => ['string', 'max:20', + Rule::unique('users', 'national_id')->ignore($this->user->id),], + 'password' => 'string|min:8|confirmed', + 'email' => ['email', 'max:255', + Rule::unique('users', 'email')->ignore($this->user->id),], + 'birth_date' => 'nullable|date', + 'phone_number' => ['string', 'max:20', + Rule::unique('users', 'phone_number')->ignore($this->user->id),], + 'postal_code' => 'nullable|string|max:20', + 'address' => 'nullable|string|max:1000', + 'province_id' => 'integer|exists:provinces,id', + 'city_id' => 'integer|exists:cities,id', + ]; + } +} diff --git a/backend/app/Admin/Resources/ExpertResource.php b/backend/app/Admin/Resources/ExpertResource.php new file mode 100755 index 00000000..b7c86e1c --- /dev/null +++ b/backend/app/Admin/Resources/ExpertResource.php @@ -0,0 +1,24 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'username' => $this->username, + 'email' => $this->email, + ]; + } +} + diff --git a/backend/app/Enums/BusinessTypeEnum.php b/backend/app/Enums/BusinessTypeEnum.php new file mode 100644 index 00000000..5bef3f00 --- /dev/null +++ b/backend/app/Enums/BusinessTypeEnum.php @@ -0,0 +1,66 @@ + '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]; + } +} diff --git a/backend/app/Enums/PaymentStatusEnum.php b/backend/app/Enums/PaymentStatusEnum.php new file mode 100644 index 00000000..78be8b94 --- /dev/null +++ b/backend/app/Enums/PaymentStatusEnum.php @@ -0,0 +1,23 @@ + 'unpaid', + self::Cancelled => 'cancelled', + self::Expired => 'expired', + self::Paid => 'paid', + self::Refunded => 'refunded', + }; + } +} diff --git a/backend/app/Facades/DataTable/DataTable.php b/backend/app/Facades/DataTable/DataTable.php new file mode 100755 index 00000000..63699505 --- /dev/null +++ b/backend/app/Facades/DataTable/DataTable.php @@ -0,0 +1,67 @@ +filters); + $sorting = json_decode($request->sorting); + $rels = $request->rels ?: array(); + + $dataTableInput = new DataTableInput( + $request->start, + $request->size, + $filters, + $sorting, + $rels, + $allowedFilters, + $allowedSortings, + $allowedGroupBy + ); + + $query = $this->makeQueryFromModel($mixed); + + $dataTableService = (new DataTableService($query, $dataTableInput)) + ->setAllowedFilters($allowedFilters) + ->setAllowedRelations($allowedRelations) + ->setAllowedSortings($allowedSortings) + ->setAllowedSelects($allowedSelects) + ->setAllowedGroupBy($allowedGroupBy); + + return $dataTableService->getData(); + } + + protected function makeQueryFromModel(Model|Builder $mixed): Builder + { + return ($mixed instanceof Model) ? $mixed->query() : $mixed; + } +} diff --git a/backend/app/Facades/DataTable/DataTableFacade.php b/backend/app/Facades/DataTable/DataTableFacade.php new file mode 100755 index 00000000..98f2ac64 --- /dev/null +++ b/backend/app/Facades/DataTable/DataTableFacade.php @@ -0,0 +1,13 @@ +putFileAs( + $path, + $file, + $name ?? Str::uuid() . '.' . $file->extension() + ); + } + + /** + * @param string $filePath + * @param bool $url_is_absolute + * @param string $disk + * @return void + * @throws InvalidArgumentException when filePath is empty. + */ + public function delete(string $filePath, bool $url_is_absolute = false, string $disk = 'public'): void + { + if (!$filePath){ + throw new InvalidArgumentException('File path is invalid.'); + } + + if ($url_is_absolute) { + $needle = 'storage/'; + $pos = strpos($filePath, $needle); + $filePath = substr($filePath, $pos + strlen($needle)); + } + + if (Storage::disk($disk)->exists($filePath)) { + Storage::disk($disk)->delete($filePath); + } + } + + public function deleteContent($file_path): bool + { + if (file_exists($file_path)) { + file_put_contents($file_path, ''); + + return true; + } + return false; + } + + public function tail($file_path, $lines = 100, $buffer = 2048): bool|string + { + // Open file + $file = @fopen($file_path, "rb"); + if ($file === false) { + return false; + } + + // Jump to last character + fseek($file, -1, SEEK_END); + + // Read it and adjust line number if necessary + // (Otherwise the result would be wrong if file doesn't end with a blank line) + if (fread($file, 1) != "\n") { + $lines -= 1; + } + + // Start reading + $output = ''; + $chunk = ''; + + // While we would like more + while (ftell($file) > 0 && $lines >= 0) { + + // Figure out how far back we should jump + $seek = min(ftell($file), $buffer); + + // Do the jump (backwards, relative to where we are) + fseek($file, -$seek, SEEK_CUR); + + // Read a chunk and prepend it to our output + $output = ($chunk = fread($file, $seek)) . $output; + + // Jump back to where we started reading + fseek($file, -mb_strlen($chunk, '8bit'), SEEK_CUR); + + // Decrease our line counter + $lines -= substr_count($chunk, "\n"); + } + + // While we have too many lines + // (Because of buffer size we might have read too many) + while ($lines++ < 0) { + + // Find first newline and remove all text before that + $output = substr($output, strpos($output, "\n") + 1); + } + + // Close file and return + fclose($file); + return trim($output); + } + + public function deleteDirectory(string $path, string $disk = 'public'): void + { + Storage::disk($disk)->deleteDirectory($path); + } +} diff --git a/backend/app/Facades/File/FileFacade.php b/backend/app/Facades/File/FileFacade.php new file mode 100755 index 00000000..daa9cd9f --- /dev/null +++ b/backend/app/Facades/File/FileFacade.php @@ -0,0 +1,13 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/City.php b/backend/app/Models/City.php new file mode 100755 index 00000000..445e69c9 --- /dev/null +++ b/backend/app/Models/City.php @@ -0,0 +1,15 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/Document.php b/backend/app/Models/Document.php new file mode 100755 index 00000000..02d0d2f3 --- /dev/null +++ b/backend/app/Models/Document.php @@ -0,0 +1,30 @@ + */ + use HasFactory; + + protected $guarded = ['id']; + + public function documentable(): MorphTo + { + return $this->morphTo(); + } + + protected function url(): Attribute + { + return Attribute::make( + get: fn($value) => Storage::disk('public')->url($value) + ); + } +} diff --git a/backend/app/Models/Expert.php b/backend/app/Models/Expert.php new file mode 100755 index 00000000..ca4912a5 --- /dev/null +++ b/backend/app/Models/Expert.php @@ -0,0 +1,24 @@ + */ + + use Notifiable,HasFactory,HasRoles; + + protected $guarded = ['id']; + protected string $guard_name = 'web'; +} diff --git a/backend/app/Models/FibTransaction.php b/backend/app/Models/FibTransaction.php new file mode 100644 index 00000000..c208c0a7 --- /dev/null +++ b/backend/app/Models/FibTransaction.php @@ -0,0 +1,14 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/FibTransactionStatus.php b/backend/app/Models/FibTransactionStatus.php new file mode 100644 index 00000000..1f7d4125 --- /dev/null +++ b/backend/app/Models/FibTransactionStatus.php @@ -0,0 +1,12 @@ + */ + use HasFactory; +} diff --git a/backend/app/Models/PasswordResetOtp.php b/backend/app/Models/PasswordResetOtp.php new file mode 100644 index 00000000..0be42dab --- /dev/null +++ b/backend/app/Models/PasswordResetOtp.php @@ -0,0 +1,10 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/PaymentStatus.php b/backend/app/Models/PaymentStatus.php new file mode 100644 index 00000000..b173c343 --- /dev/null +++ b/backend/app/Models/PaymentStatus.php @@ -0,0 +1,15 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/Province.php b/backend/app/Models/Province.php new file mode 100755 index 00000000..854975a8 --- /dev/null +++ b/backend/app/Models/Province.php @@ -0,0 +1,15 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/Transaction.php b/backend/app/Models/Transaction.php new file mode 100644 index 00000000..a685ed3d --- /dev/null +++ b/backend/app/Models/Transaction.php @@ -0,0 +1,15 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Models/User.php b/backend/app/Models/User.php old mode 100644 new mode 100755 index f6ba1d2e..20e0ad4a --- a/backend/app/Models/User.php +++ b/backend/app/Models/User.php @@ -4,29 +4,36 @@ namespace App\Models; // use Illuminate\Contracts\Auth\MustVerifyEmail; use Database\Factories\UserFactory; -use Illuminate\Database\Eloquent\Attributes\Fillable; +use Illuminate\Database\Eloquent\Attributes\Guarded; use Illuminate\Database\Eloquent\Attributes\Hidden; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Database\Eloquent\Relations\MorphToMany; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; +use Illuminate\Support\Facades\Hash; +use Laravel\Passport\Bridge\Client; +use Laravel\Passport\HasApiTokens; -#[Fillable(['name', 'email', 'password'])] -#[Hidden(['password', 'remember_token'])] +#[Guarded(['id'])] +#[Hidden(['password'])] class User extends Authenticatable { /** @use HasFactory */ - use HasFactory, Notifiable; + use HasFactory, Notifiable, HasApiTokens; + protected $guarded = ['id']; - /** - * Get the attributes that should be cast. - * - * @return array - */ - protected function casts(): array + public function documents(): MorphToMany { - return [ - 'email_verified_at' => 'datetime', - 'password' => 'hashed', - ]; + return $this->morphToMany(Document::class, 'documentable'); + } + + public function validateForPassportPasswordGrant(string $password): bool + { + return Hash::check($password, $this->password); + } + + public function findForPassport(string $username, Client $client): User + { + return $this->where('username', $username)->first(); } } diff --git a/backend/app/Models/UserGateway.php b/backend/app/Models/UserGateway.php new file mode 100644 index 00000000..c1bd6f5e --- /dev/null +++ b/backend/app/Models/UserGateway.php @@ -0,0 +1,15 @@ + */ + use HasFactory; + + protected $guarded = ['id']; +} diff --git a/backend/app/Notifications/ResetPasswordOtpNotification.php b/backend/app/Notifications/ResetPasswordOtpNotification.php new file mode 100644 index 00000000..4abe6125 --- /dev/null +++ b/backend/app/Notifications/ResetPasswordOtpNotification.php @@ -0,0 +1,32 @@ +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.'); + } +} diff --git a/backend/app/Providers/AppServiceProvider.php b/backend/app/Providers/AppServiceProvider.php old mode 100644 new mode 100755 index 452e6b65..c542af2e --- a/backend/app/Providers/AppServiceProvider.php +++ b/backend/app/Providers/AppServiceProvider.php @@ -3,6 +3,8 @@ namespace App\Providers; use Illuminate\Support\ServiceProvider; +use Laravel\Passport\Passport; +use Carbon\CarbonInterval; class AppServiceProvider extends ServiceProvider { @@ -19,6 +21,9 @@ class AppServiceProvider extends ServiceProvider */ public function boot(): void { - // + Passport::enablePasswordGrant(); + Passport::tokensExpireIn(CarbonInterval::minutes(1)); + Passport::refreshTokensExpireIn(CarbonInterval::minutes(5)); + Passport::personalAccessTokensExpireIn(CarbonInterval::minutes(1)); } } diff --git a/backend/app/Providers/DataTableServiceProvider.php b/backend/app/Providers/DataTableServiceProvider.php new file mode 100755 index 00000000..c16c0ee5 --- /dev/null +++ b/backend/app/Providers/DataTableServiceProvider.php @@ -0,0 +1,27 @@ +app->bind('datatable', function () { + return new DataTable(); + }); + } + + /** + * Bootstrap services. + */ + public function boot(): void + { + // + } +} diff --git a/backend/app/Providers/FileServiceProvider.php b/backend/app/Providers/FileServiceProvider.php new file mode 100755 index 00000000..3174c6af --- /dev/null +++ b/backend/app/Providers/FileServiceProvider.php @@ -0,0 +1,27 @@ +app->bind('file', function () { + return new File(); + }); + } + + /** + * Bootstrap services. + */ + public function boot(): void + { + // + } +} diff --git a/backend/app/Services/Auth/PasswordResetOtpService.php b/backend/app/Services/Auth/PasswordResetOtpService.php new file mode 100644 index 00000000..aa73ecdd --- /dev/null +++ b/backend/app/Services/Auth/PasswordResetOtpService.php @@ -0,0 +1,103 @@ +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(); + } +} diff --git a/backend/app/Services/DataTable/DataTableInput.php b/backend/app/Services/DataTable/DataTableInput.php new file mode 100755 index 00000000..1bbe5200 --- /dev/null +++ b/backend/app/Services/DataTable/DataTableInput.php @@ -0,0 +1,83 @@ +start; + } + + public function getSize(): ?int + { + return $this->size; + } + + /** + * @return array returns an array of Filter objects + */ + public function getFilters(): array + { + $filters = array(); + + foreach ($this->filters as $filter) { + $filters[] = new Filter( + $filter->id, + $filter->value, + $filter->fn, + $filter->datatype, + $this->allowedFilters + ); + } + + return $filters; + } + + /** + * @return array + */ + public function getSorting(): ?array + { + $sorts = []; + if (!empty($this->sorting)){ + foreach ($this->sorting as $sort) { + $sorts[] = new Sort($sort->id, $sort->desc, $this->allowedSortings); + } + } + return $sorts; + } + + public function getRelations(): array + { + return $this->rels; + } + + public function getGroupBy(): ?array + { + return $this->GroupBy; + } +} diff --git a/backend/app/Services/DataTable/DataTableService.php b/backend/app/Services/DataTable/DataTableService.php new file mode 100755 index 00000000..5755ad1d --- /dev/null +++ b/backend/app/Services/DataTable/DataTableService.php @@ -0,0 +1,128 @@ +allowedFilters = $allowedFilters; + return $this; + } + + public function setAllowedRelations(array $allowedRelations): DataTableService + { + $this->allowedRelations = $allowedRelations; + return $this; + } + + public function setAllowedSortings(array $allowedSortings): DataTableService + { + $this->allowedSortings = $allowedSortings; + return $this; + } + + public function setAllowedSelects(array $allowedSelects): DataTableService + { + $this->allowedSelects = $allowedSelects; + return $this; + } + + public function setAllowedGroupBy(array $allowedGroupBy): DataTableService + { + $this->allowedGroupBy = $allowedGroupBy; + return $this; + } + + /** + * Handle 'getData' operations + * @return array + */ + public function getData(): array + { + $query = $this->buildQuery(); + $data = $query->get(); + + return array( + 'data' => $data, + 'meta' => [ + 'totalRowCount' => $this->totalRowCount + ] + ); + } + + protected function buildQuery(): Builder + { + $query = $this->query; + + foreach ($this->dataTableInput->getFilters() as $filter) { + $query = (new ApplyFilter($query, $filter))->apply(); + } + + $query = $this->applySelect($query, $this->allowedSelects); + $query = $this->includeRelationsInQuery($query, $this->allowedRelations); + $query = $this->applyGroupBy($query, $this->allowedGroupBy); + + $this->totalRowCount = $query->count(); + + if (!is_null($this->dataTableInput->getStart())) { + $query->offset($this->dataTableInput->getStart()); + } + + if(!is_null($this->dataTableInput->getSize())){ + $query->limit($this->dataTableInput->getSize()); + } + + $sorting = $this->dataTableInput->getSorting(); + foreach ($sorting as $sort){ + $query = (new ApplySort($query, $sort))->apply(); + } + + return $query; + } + + protected function applySelect(Builder $query, array $selectedFields): Builder + { + if (!empty($selectedFields)) { + $query->select($selectedFields); + } + + return $query; + } + + protected function applyGroupBy(Builder $query, array $groupBy): Builder + { + return empty($groupBy) ? $query : $query->groupBy($groupBy); + } + + protected function includeRelationsInQuery(Builder $query, array $rels): Builder + { + if (!empty($rels)) { + $query->with($rels); + } + + return $query; + } + + // (later) define mapping of relation names to prevent relation name expose. + // (later) define mapping of column names to prevent column name expose. +} diff --git a/backend/app/Services/DataTable/Enums/DataType.php b/backend/app/Services/DataTable/Enums/DataType.php new file mode 100755 index 00000000..e16e98cd --- /dev/null +++ b/backend/app/Services/DataTable/Enums/DataType.php @@ -0,0 +1,15 @@ +fieldName = $fieldName; + parent::__construct($message, $code, $previous); + } + + public function getFieldName() + { + return $this->fieldName; + } +} diff --git a/backend/app/Services/DataTable/Exceptions/InvalidParameterInterface.php b/backend/app/Services/DataTable/Exceptions/InvalidParameterInterface.php new file mode 100755 index 00000000..3e7b3c73 --- /dev/null +++ b/backend/app/Services/DataTable/Exceptions/InvalidParameterInterface.php @@ -0,0 +1,7 @@ +fieldName = $fieldName; + parent::__construct($message, $code, $previous); + } + + public function getFieldName() + { + return $this->fieldName; + } +} diff --git a/backend/app/Services/DataTable/Exceptions/InvalidSortingException.php b/backend/app/Services/DataTable/Exceptions/InvalidSortingException.php new file mode 100755 index 00000000..d1704699 --- /dev/null +++ b/backend/app/Services/DataTable/Exceptions/InvalidSortingException.php @@ -0,0 +1,21 @@ +fieldName = $fieldName; + parent::__construct($message, $code, $previous); + } + + public function getFieldName() + { + return $this->fieldName; + } +} diff --git a/backend/app/Services/DataTable/Filter/ApplyFilter.php b/backend/app/Services/DataTable/Filter/ApplyFilter.php new file mode 100755 index 00000000..60ac88ea --- /dev/null +++ b/backend/app/Services/DataTable/Filter/ApplyFilter.php @@ -0,0 +1,84 @@ +filter; + $query = $this->query; + + $searchType = SearchType::from($filter->getFn()); + switch ($searchType) { + case SearchType::CONTAINS: + $this->searchFilter = new FilterContains($query, $filter); + break; + + case SearchType::EQUALS: + $this->searchFilter = new FilterEquals($query, $filter); + break; + + case SearchType::NOT_EQUALS: + $this->searchFilter = new FilterNotEquals($query, $filter); + break; + + case SearchType::BETWEEN: + $this->searchFilter = new FilterBetween($query, $filter); + break; + + case SearchType::GREATER_THAN: + $this->searchFilter = new FilterGreaterThan($query, $filter); + break; + + case SearchType::LESS_THAN: + $this->searchFilter = new FilterLessThan($query, $filter); + break; + + default: + $searchFunction = $filter->getFn(); + throw new InvalidFilterException($searchFunction, "search function `$searchFunction` is invalid."); + + } + + $relation = $this->filter->getRelation(); + return method_exists($this->query->getModel(), $relation) ? $this->applyFilterToRelation($relation) : $this->searchFilter->apply(); + } + + protected function applyFilterToRelation(string $relation): Builder + { + return $this->query->whereHas($relation, function (Builder $query) { + $this->filter->removeRelationFromId(); + $this->applyFilter($query, $this->filter); + }); + } + + private function applyFilter(Builder $query, Filter $filter): Builder + { + return (new ApplyFilter($query, $filter))->apply(); + } +} diff --git a/backend/app/Services/DataTable/Filter/Filter.php b/backend/app/Services/DataTable/Filter/Filter.php new file mode 100755 index 00000000..22362a1d --- /dev/null +++ b/backend/app/Services/DataTable/Filter/Filter.php @@ -0,0 +1,73 @@ +isValid($this, $this->allowedFilters); + } + + public function getId(): string + { + return $this->id; + } + + public function getValue(): array|int|string + { + return $this->value; + } + + public function getFn(): string + { + return $this->fn; + } + + public function getDatatype(): string + { + return $this->datatype; + } + + public function getRelation(): string + { + $fieldArray = explode('.', $this->id); + return count($fieldArray) > 1 ? $fieldArray[0] : ''; + } + + public function getColumn(): string + { + $fieldArray = explode('.', $this->id); + return array_pop($fieldArray); + } + + public function removeRelationFromId(): void + { + $this->id = $this->getColumn(); + } + + public function setValue(int|array|string $value): void + { + $this->value = $value; + } + +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/FilterBetween.php b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterBetween.php new file mode 100755 index 00000000..7a6292da --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterBetween.php @@ -0,0 +1,33 @@ +query; + [$minVal, $maxVal] = $this->filter->getValue(); + + if ($minVal) { + if ($this->filter->getDatatype() == "date") { + $minVal = $minVal . " 00:00:00"; + } + $this->filter->setValue($minVal); + $query = (new FilterGreaterThanOrEqual($this->query, $this->filter))->apply(); + } + + if ($maxVal) { + if ($this->filter->getDatatype() == "date") { + $maxVal = $maxVal . " 23:59:59"; + } + $this->filter->setValue($maxVal); + $query = (new FilterLessThanOrEqual($this->query, $this->filter))->apply(); + } + + return $query; + } +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/FilterContains.php b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterContains.php new file mode 100755 index 00000000..686fe9f1 --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterContains.php @@ -0,0 +1,31 @@ +filter->getId(); + $value = '%' . $this->filter->getValue() . '%'; + + if ($this->filter->getDatatype() == DataType::TEXT->value) { + $query = $this->searchIgnoreCase($column, $value); + + } else { + $query = $this->query->where($column, 'LIKE', $value); + } + + return $query; + } + + private function searchIgnoreCase(string $column, string $value): Builder + { + $value = strtolower($value); + return $this->query->whereRaw("LOWER($column) LIKE ?", [$value]); + } +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/FilterEquals.php b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterEquals.php new file mode 100755 index 00000000..594ce87d --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterEquals.php @@ -0,0 +1,30 @@ +filter->getId(); + $value = $this->filter->getValue(); + + if ($this->filter->getDatatype() == DataType::TEXT->value) { + $query = $this->searchIgnoreCase($column, $value); + } else { + $query = $this->query->where($column, $value); + } + + return $query; + } + + private function searchIgnoreCase(string $column, string $value): Builder + { + $value = strtolower($value); + return $this->query->whereRaw("LOWER($column) = ?", [$value]); + } +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/FilterGreaterThan.php b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterGreaterThan.php new file mode 100755 index 00000000..30da5d32 --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterGreaterThan.php @@ -0,0 +1,18 @@ +filter->getDatatype() == DataType::NUMERIC) ? + (float)$this->filter->getValue() : $this->filter->getValue(); + + return $this->query->where($this->filter->getId(), '>', $value); + } +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/FilterGreaterThanOrEqual.php b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterGreaterThanOrEqual.php new file mode 100755 index 00000000..8e97248a --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterGreaterThanOrEqual.php @@ -0,0 +1,18 @@ +filter->getDatatype() == DataType::NUMERIC) ? + (float)$this->filter->getValue() : $this->filter->getValue(); + + return $this->query->where($this->filter->getId(), '>=', $value); + } +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/FilterLessThan.php b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterLessThan.php new file mode 100755 index 00000000..4069b9e0 --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterLessThan.php @@ -0,0 +1,18 @@ +filter->getDatatype() == DataType::NUMERIC) ? + (float)$this->filter->getValue() : $this->filter->getValue(); + + return $this->query->where($this->filter->getId(), '<', $value); + } +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/FilterLessThanOrEqual.php b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterLessThanOrEqual.php new file mode 100755 index 00000000..84409052 --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterLessThanOrEqual.php @@ -0,0 +1,18 @@ +filter->getDatatype() == DataType::NUMERIC) ? + (float)$this->filter->getValue() : $this->filter->getValue(); + + return $this->query->where($this->filter->getId(), '<=', $value); + } +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/FilterNotEquals.php b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterNotEquals.php new file mode 100755 index 00000000..e525f2b7 --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/FilterNotEquals.php @@ -0,0 +1,17 @@ +filter->getId(); + $value = $this->filter->getValue(); + + return $this->query->whereNot($column, $value); + } +} diff --git a/backend/app/Services/DataTable/Filter/SearchFunctions/SearchFilter.php b/backend/app/Services/DataTable/Filter/SearchFunctions/SearchFilter.php new file mode 100755 index 00000000..d4dcbf6a --- /dev/null +++ b/backend/app/Services/DataTable/Filter/SearchFunctions/SearchFilter.php @@ -0,0 +1,22 @@ +query; + + if (!is_null($this->sort)) { + $query->orderBy($this->sort->getId(), $this->sort->getDirection()); + } + + return $query; + } +} diff --git a/backend/app/Services/DataTable/Sort/Sort.php b/backend/app/Services/DataTable/Sort/Sort.php new file mode 100755 index 00000000..5196797a --- /dev/null +++ b/backend/app/Services/DataTable/Sort/Sort.php @@ -0,0 +1,39 @@ +isValid($this, $this->allowedSortings); + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + public function getDirection(): string + { + return $this->desc === true ? 'desc' : 'asc'; + } +} diff --git a/backend/app/Services/DataTable/Validators/FilterValidator.php b/backend/app/Services/DataTable/Validators/FilterValidator.php new file mode 100755 index 00000000..ea837f9e --- /dev/null +++ b/backend/app/Services/DataTable/Validators/FilterValidator.php @@ -0,0 +1,69 @@ +isAllowed($filter, $allowedFilters)) { + $filterId = $filter->getId(); + throw new InvalidFilterException($filter->getId(), "filtering field `$filterId` is not allowed."); + } + + if (!$this->isValidSearchFunction($filter)) { + $searchFunction = $filter->getFn(); + throw new InvalidFilterException($searchFunction, "search function `$searchFunction` is invalid."); + } + + if ($this->isValidDataType($filter) == -1) { + throw new InvalidFilterException(null, "datatype property is not set in `filters` array."); + } + + if (!$this->isValidDataType($filter)) { + $datatype = $filter->getDatatype(); + throw new InvalidFilterException($datatype, "datatype `$datatype` is invalid."); + } + + return true; + } + + protected function isAllowed(Filter $filter, array $allowedFilters): bool + { + return $allowedFilters == ['*'] || in_array($filter->getId(), $allowedFilters); + } + + protected function isValidSearchFunction(Filter $filter): bool + { + $searchFunction = $filter->getFn(); + return isset($searchFunction) && in_array($searchFunction, SearchType::values()); + } + + protected function isValidDataType(Filter $filter): int + { + if (!property_exists($filter, 'datatype')) + return -1; + + return $filter->getDatatype() && in_array($filter->getDatatype(), DataType::values()) ? 1 : 0; + } +} diff --git a/backend/app/Services/DataTable/Validators/RelationValidator.php b/backend/app/Services/DataTable/Validators/RelationValidator.php new file mode 100755 index 00000000..ab87382b --- /dev/null +++ b/backend/app/Services/DataTable/Validators/RelationValidator.php @@ -0,0 +1,25 @@ +isAllowed($sorting, $allowedSortings)) { + $sortId = $sorting->getId(); + throw new InvalidSortingException($sortId, "sorting field `$sortId` is not allowed."); + } + + return true; + } + + protected function isAllowed(Sort $sorting, array $allowedSortings): bool + { + return $allowedSortings == ['*'] || in_array($sorting->getId(), $allowedSortings); + } +} diff --git a/backend/app/Services/FIB/AuthorizationService.php b/backend/app/Services/FIB/AuthorizationService.php new file mode 100755 index 00000000..8f1e40df --- /dev/null +++ b/backend/app/Services/FIB/AuthorizationService.php @@ -0,0 +1,57 @@ +url = config('fib.authorization.url'); + $this->channelName = 'fib_authorization'; + $this->inputParameters = [ + 'client_id' => config('fib.authorization.client_id'), + 'client_secret' => config('fib.authorization.client_secret'), + 'grant_type' => 'client_credentials', + ]; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::asForm() + ->throw() + ->post($this->url, $this->inputParameters) + ->json(); + } +} diff --git a/backend/app/Services/FIB/CancelPaymentService.php b/backend/app/Services/FIB/CancelPaymentService.php new file mode 100755 index 00000000..8cfdb72a --- /dev/null +++ b/backend/app/Services/FIB/CancelPaymentService.php @@ -0,0 +1,62 @@ +url = config('fib.cancelPayment.url'); + $this->channelName = ''; + } + + public function setHeaders(): void + { + $this->headers = [ + 'Authorization' => 'Bearer ' . $this->accessToken, + 'Content-Type' => 'application/json', + ]; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::withHeaders($this->headers) + ->throw() + ->withoutVerifying() + ->post($this->url) + ->json(); + } +} diff --git a/backend/app/Services/FIB/CheckPaymentStatusService.php b/backend/app/Services/FIB/CheckPaymentStatusService.php new file mode 100755 index 00000000..6a5ff4e5 --- /dev/null +++ b/backend/app/Services/FIB/CheckPaymentStatusService.php @@ -0,0 +1,51 @@ +url = config('fib.checkPaymentStatus.url'); + $this->channelName = ''; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::throw() + ->withoutVerifying() + ->post($this->url) + ->json(); + } +} diff --git a/backend/app/Services/FIB/CreatePaymentService.php b/backend/app/Services/FIB/CreatePaymentService.php new file mode 100755 index 00000000..9df973ad --- /dev/null +++ b/backend/app/Services/FIB/CreatePaymentService.php @@ -0,0 +1,73 @@ +url = config('fib.createPayment.url'); + $this->channelName = ''; + } + + public function setAccessToken(string $accessToken): void + { + $this->accessToken = $accessToken; + } + + public function setHeaders(): void + { + $this->headers = [ + 'Authorization' => 'Bearer ' . $this->accessToken, + 'Content-Type' => 'application/json', + ]; + } + + public function setInputParameters(array $inputParameters): void + { + $this->inputParameters = $inputParameters; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::withHeaders($this->headers) + ->throw() + ->withoutVerifying() + ->post($this->url, $this->inputParameters) + ->json(); + } +} diff --git a/backend/app/Services/FIB/FIBClient.php b/backend/app/Services/FIB/FIBClient.php new file mode 100755 index 00000000..be22b64c --- /dev/null +++ b/backend/app/Services/FIB/FIBClient.php @@ -0,0 +1,86 @@ +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'; + } +} diff --git a/backend/app/Services/FIB/RefundService.php b/backend/app/Services/FIB/RefundService.php new file mode 100755 index 00000000..52d18d6f --- /dev/null +++ b/backend/app/Services/FIB/RefundService.php @@ -0,0 +1,62 @@ +url = config('fib.refund.url'); + $this->channelName = ''; + } + + public function setHeaders(): void + { + $this->headers = [ + 'Authorization' => 'Bearer ' . $this->accessToken, + 'Content-Type' => 'application/json', + ]; + } + + /** + * @throws Exception + */ + public function run(): array + { + try { + return $this->sendRequest(); + } + catch (Exception $e) { + Log::channel($this->channelName) + ->error(get_class($this), + [ + 'message' => $e->getMessage(), + ] + ); + + throw $e; + } + } + + /** + * @throws ConnectionException + */ + public function sendRequest(): array + { + return Http::withHeaders($this->headers) + ->throw() + ->withoutVerifying() + ->post($this->url) + ->json(); + } +} diff --git a/backend/app/Services/Payments/DTO/FIBPaymentCreateDTO.php b/backend/app/Services/Payments/DTO/FIBPaymentCreateDTO.php new file mode 100644 index 00000000..e09cab6b --- /dev/null +++ b/backend/app/Services/Payments/DTO/FIBPaymentCreateDTO.php @@ -0,0 +1,38 @@ +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, + ]); + } +} diff --git a/backend/app/Services/Payments/DTO/PaymentCreateDTO.php b/backend/app/Services/Payments/DTO/PaymentCreateDTO.php new file mode 100644 index 00000000..a3129a3a --- /dev/null +++ b/backend/app/Services/Payments/DTO/PaymentCreateDTO.php @@ -0,0 +1,46 @@ +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, + ]); + } +} diff --git a/backend/app/Services/Payments/FibAdapter.php b/backend/app/Services/Payments/FibAdapter.php new file mode 100644 index 00000000..0e6adb2b --- /dev/null +++ b/backend/app/Services/Payments/FibAdapter.php @@ -0,0 +1,37 @@ +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(); + } +} diff --git a/backend/app/Services/Payments/PaymentService.php b/backend/app/Services/Payments/PaymentService.php new file mode 100644 index 00000000..d50d8b7f --- /dev/null +++ b/backend/app/Services/Payments/PaymentService.php @@ -0,0 +1,72 @@ +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()); + } + } +} diff --git a/backend/app/Traits/ApiResponse.php b/backend/app/Traits/ApiResponse.php new file mode 100755 index 00000000..5c9997d8 --- /dev/null +++ b/backend/app/Traits/ApiResponse.php @@ -0,0 +1,31 @@ +json([ + 'data' => $data + ], $statusCode); + } + + $message = $message ?? __('messages.successful'); + + return response()->json([ + 'message' => $message + ], $statusCode); + } + + public function errorResponse(string $message, string $type = 'logical_exception', int $statusCode = 422): JsonResponse + { + return response()->json([ + 'type' => $type, + 'message' => $message + ], $statusCode); + } +} diff --git a/backend/app/User/Controllers/AuthController.php b/backend/app/User/Controllers/AuthController.php new file mode 100755 index 00000000..433624cc --- /dev/null +++ b/backend/app/User/Controllers/AuthController.php @@ -0,0 +1,64 @@ +create([ + 'username' => $request->username, + 'email' => $request->email, + 'password' => Hash::make($request->password), + ]); + + Auth::guard('web')->login($user); + + $request->session()->regenerate(); + + return $this->successResponse(); + } + + public function login(LoginRequest $request): JsonResponse + { + $credentials = ['password' => $request->password,]; + + if (filter_var($request->login, FILTER_VALIDATE_EMAIL)) { + $credentials['email'] = $request->login; + } else { + $credentials['username'] = $request->login; + } + + if (Auth::attempt($credentials)) + { + $request->session()->regenerate(); + + return $this->successResponse(); + } + + return $this->errorResponse(__('messages.incorrect_or_username_password')); + } + + public function logout(Request $request): JsonResponse + { + Auth::guard('web')->logout(); + + $request->session()->invalidate(); + + $request->session()->regenerateToken(); + + return $this->successResponse(); + } +} diff --git a/backend/app/User/Controllers/CityController.php b/backend/app/User/Controllers/CityController.php new file mode 100755 index 00000000..c14f5677 --- /dev/null +++ b/backend/app/User/Controllers/CityController.php @@ -0,0 +1,24 @@ +where('province_id', '=', $request->query('province_id')) + ->get(['id', 'name']); + + return $this->successResponse($cities); + } +} diff --git a/backend/app/User/Controllers/DocumentationController.php b/backend/app/User/Controllers/DocumentationController.php new file mode 100755 index 00000000..7c6b8092 --- /dev/null +++ b/backend/app/User/Controllers/DocumentationController.php @@ -0,0 +1,42 @@ +user(); + + foreach ($request->documents as $document) { + $user->documents()->create([ + 'title' => $document['title'], + 'url' => FileFacade::save($document['file'], "/{$user->id}/documents", $document['title']), + ]); + } + + return $this->successResponse(); + } + + public function edit(EditRequest $request): JsonResponse + { + $user = Auth::guard('web')->user(); + + foreach ($request->documents as $document) { + $user->documents()->sync(); + } + + return $this->successResponse(); + } +} diff --git a/backend/app/User/Controllers/ForgotPasswordOtpController.php b/backend/app/User/Controllers/ForgotPasswordOtpController.php new file mode 100644 index 00000000..51e3889b --- /dev/null +++ b/backend/app/User/Controllers/ForgotPasswordOtpController.php @@ -0,0 +1,89 @@ +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.', + ]); + } +} diff --git a/backend/app/User/Controllers/GatewayManagementController.php b/backend/app/User/Controllers/GatewayManagementController.php new file mode 100644 index 00000000..690d364e --- /dev/null +++ b/backend/app/User/Controllers/GatewayManagementController.php @@ -0,0 +1,97 @@ +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(); + } +} diff --git a/backend/app/User/Controllers/Payment/PaymentController.php b/backend/app/User/Controllers/Payment/PaymentController.php new file mode 100644 index 00000000..69e7cd97 --- /dev/null +++ b/backend/app/User/Controllers/Payment/PaymentController.php @@ -0,0 +1,35 @@ +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; + } + } +} diff --git a/backend/app/User/Controllers/ProfileController.php b/backend/app/User/Controllers/ProfileController.php new file mode 100755 index 00000000..3a055d91 --- /dev/null +++ b/backend/app/User/Controllers/ProfileController.php @@ -0,0 +1,80 @@ +successResponse(new UserResource(Auth::user())); + } + + /** + * @throws Throwable + */ + public function edit(EditRequest $request): JsonResponse + { + $user = Auth::user(); + $province = Province::query()->find($request->province_id); + $city = City::query()->find($request->city_id); + + 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(); + } + + public function changePassword(ChangePasswordRequest $request): JsonResponse + { + $user = Auth::user(); + + if (! Hash::check($request->current_password, $user->password)) { + return $this->errorResponse(__('messages.incorrect_current_password')); + } + + $user->update([ + 'password' => Hash::make($request->new_password), + ]); + + return $this->successResponse(); + } +} diff --git a/backend/app/User/Controllers/ProvinceController.php b/backend/app/User/Controllers/ProvinceController.php new file mode 100755 index 00000000..d73254d3 --- /dev/null +++ b/backend/app/User/Controllers/ProvinceController.php @@ -0,0 +1,17 @@ +successResponse(Province::all(['id', 'name'])); + } +} diff --git a/backend/app/User/Events/LoginEmailEvent.php b/backend/app/User/Events/LoginEmailEvent.php new file mode 100755 index 00000000..f3199341 --- /dev/null +++ b/backend/app/User/Events/LoginEmailEvent.php @@ -0,0 +1,23 @@ +user; + + Mail::to($user->email)->send( + new LoginNotificationMail($user) + ); + } +} diff --git a/backend/app/User/Requests/Auth/LoginRequest.php b/backend/app/User/Requests/Auth/LoginRequest.php new file mode 100755 index 00000000..98a46690 --- /dev/null +++ b/backend/app/User/Requests/Auth/LoginRequest.php @@ -0,0 +1,30 @@ + + */ + public function rules(): array + { + return [ + 'login' => 'required|string', + 'password' => 'required|string', + ]; + } +} diff --git a/backend/app/User/Requests/Auth/RegisterRequest.php b/backend/app/User/Requests/Auth/RegisterRequest.php new file mode 100755 index 00000000..3def14d6 --- /dev/null +++ b/backend/app/User/Requests/Auth/RegisterRequest.php @@ -0,0 +1,31 @@ + + */ + public function rules(): array + { + return [ + 'username' => 'required|unique:users,username', + 'email' => 'required|email|unique:users,email', + 'password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6|confirmed', + ]; + } +} diff --git a/backend/app/User/Requests/Documentation/EditRequest.php b/backend/app/User/Requests/Documentation/EditRequest.php new file mode 100755 index 00000000..25c3e1d2 --- /dev/null +++ b/backend/app/User/Requests/Documentation/EditRequest.php @@ -0,0 +1,31 @@ + + */ + public function rules(): array + { + return [ + 'documents' => 'required|array', + 'documents.*.file' => 'required|file|mimes:pdf,jpg,jpeg,png|max:2048', + 'documents.*.title' => 'required|string', + ]; + } +} diff --git a/backend/app/User/Requests/Documentation/UploadRequest.php b/backend/app/User/Requests/Documentation/UploadRequest.php new file mode 100755 index 00000000..b832c916 --- /dev/null +++ b/backend/app/User/Requests/Documentation/UploadRequest.php @@ -0,0 +1,31 @@ + + */ + public function rules(): array + { + return [ + 'documents' => 'required|array', + 'documents.*.file' => 'required|file|mimes:pdf,jpg,jpeg,png|max:2048', + 'documents.*.title' => 'required|string', + ]; + } +} diff --git a/backend/app/User/Requests/Gateway/StoreRequest.php b/backend/app/User/Requests/Gateway/StoreRequest.php new file mode 100644 index 00000000..f7562dd8 --- /dev/null +++ b/backend/app/User/Requests/Gateway/StoreRequest.php @@ -0,0 +1,37 @@ +user()->kyc_status; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + 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', + ]; + } +} diff --git a/backend/app/User/Requests/Gateway/UpdateRequest.php b/backend/app/User/Requests/Gateway/UpdateRequest.php new file mode 100644 index 00000000..749eb4da --- /dev/null +++ b/backend/app/User/Requests/Gateway/UpdateRequest.php @@ -0,0 +1,33 @@ +user()->kyc_status; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + 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', + ]; + } +} diff --git a/backend/app/User/Requests/Payment/FIB/StoreRequest.php b/backend/app/User/Requests/Payment/FIB/StoreRequest.php new file mode 100644 index 00000000..7ef61312 --- /dev/null +++ b/backend/app/User/Requests/Payment/FIB/StoreRequest.php @@ -0,0 +1,36 @@ +user()->kyc_status; + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'username' => ['required'], + 'track_id' => ['required'], + 'amount' => ['required'], + 'currency' => ['required'], + 'callback_url' => ['required'], + 'user_gateway_id' => ['required'], + ]; + } +} diff --git a/backend/app/User/Requests/Profile/ChangePasswordRequest.php b/backend/app/User/Requests/Profile/ChangePasswordRequest.php new file mode 100755 index 00000000..60e53c56 --- /dev/null +++ b/backend/app/User/Requests/Profile/ChangePasswordRequest.php @@ -0,0 +1,30 @@ + + */ + public function rules(): array + { + return [ + 'current_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6', + 'new_password' => 'required|string|regex:/^(?=.*[a-zA-Z])(?=.*\d).+$/|min:6', + ]; + } +} diff --git a/backend/app/User/Requests/Profile/EditRequest.php b/backend/app/User/Requests/Profile/EditRequest.php new file mode 100755 index 00000000..0467ddc2 --- /dev/null +++ b/backend/app/User/Requests/Profile/EditRequest.php @@ -0,0 +1,44 @@ + + */ + public function rules(): array + { + $user = Auth::guard('web')->user(); + + return [ + 'first_name' => 'required|string|max:255', + 'last_name' => 'required|string|max:255', + 'national_id' => [Rule::prohibitedIf($user->kyc_status == 1), 'string',], + 'email' => 'required|email|max:255', + 'address' => 'required|string', + 'postal_code' => 'required|string', + 'phone_number' => 'required|string', + 'province_id' => 'required|exists:provinces,id', + 'city_id' => 'required|exists:cities,id', + 'birth_date' => 'required|date', + 'id_card' => [Rule::prohibitedIf($user->kyc_status == 1), 'image', 'mimes:jpeg,png,jpg,gif,svg', 'max:2048'] + ]; + } +} diff --git a/backend/app/User/Resources/UserResource.php b/backend/app/User/Resources/UserResource.php new file mode 100755 index 00000000..9f98d7f8 --- /dev/null +++ b/backend/app/User/Resources/UserResource.php @@ -0,0 +1,36 @@ + + */ + public function toArray(Request $request): array + { + return [ + 'id' => $this->id, + 'username' => $this->username, + '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, + ]; + } +} diff --git a/backend/artisan b/backend/artisan old mode 100644 new mode 100755 diff --git a/backend/bootstrap/app.php b/backend/bootstrap/app.php old mode 100644 new mode 100755 index c1832766..31119ffe --- a/backend/bootstrap/app.php +++ b/backend/bootstrap/app.php @@ -7,12 +7,22 @@ use Illuminate\Foundation\Configuration\Middleware; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', + api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', + then: function () { + Route::middleware('web') + ->prefix('expert') + ->name('expert.') + ->group(base_path('routes/expert.php')); + }, ) ->withMiddleware(function (Middleware $middleware): void { - // + $middleware->web()->preventRequestForgery(['*']); }) ->withExceptions(function (Exceptions $exceptions): void { // - })->create(); + }) + ->withEvents(discover: [ + __DIR__.'/../app/User/Listeners', + ])->create(); diff --git a/backend/bootstrap/cache/.gitignore b/backend/bootstrap/cache/.gitignore old mode 100644 new mode 100755 diff --git a/backend/bootstrap/providers.php b/backend/bootstrap/providers.php old mode 100644 new mode 100755 index fc94ae60..9a7a919f --- a/backend/bootstrap/providers.php +++ b/backend/bootstrap/providers.php @@ -1,7 +1,7 @@ = 2", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "^5|^6|^7|^8|^9|^10", + "yoast/phpunit-polyfills": "^2.0.0" + }, + "bin": [ + "bin/generate-defuse-key" + ], + "type": "library", + "autoload": { + "psr-4": { + "Defuse\\Crypto\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Hornby", + "email": "taylor@defuse.ca", + "homepage": "https://defuse.ca/" + }, + { + "name": "Scott Arciszewski", + "email": "info@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "Secure PHP Encryption Library", + "keywords": [ + "aes", + "authenticated encryption", + "cipher", + "crypto", + "cryptography", + "encrypt", + "encryption", + "openssl", + "security", + "symmetric key cryptography" + ], + "support": { + "issues": "https://github.com/defuse/php-encryption/issues", + "source": "https://github.com/defuse/php-encryption/tree/v2.4.0" + }, + "time": "2023-06-19T06:10:36+00:00" + }, { "name": "dflydev/dot-access-data", "version": "v3.0.3", @@ -508,6 +575,70 @@ ], "time": "2025-03-06T22:45:56+00:00" }, + { + "name": "firebase/php-jwt", + "version": "v7.0.5", + "source": { + "type": "git", + "url": "https://github.com/googleapis/php-jwt.git", + "reference": "47ad26bab5e7c70ae8a6f08ed25ff83631121380" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/googleapis/php-jwt/zipball/47ad26bab5e7c70ae8a6f08ed25ff83631121380", + "reference": "47ad26bab5e7c70ae8a6f08ed25ff83631121380", + "shasum": "" + }, + "require": { + "php": "^8.0" + }, + "require-dev": { + "guzzlehttp/guzzle": "^7.4", + "phpfastcache/phpfastcache": "^9.2", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.5", + "psr/cache": "^2.0||^3.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0" + }, + "suggest": { + "ext-sodium": "Support EdDSA (Ed25519) signatures", + "paragonie/sodium_compat": "Support EdDSA (Ed25519) signatures when libsodium is not present" + }, + "type": "library", + "autoload": { + "psr-4": { + "Firebase\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Neuman Vong", + "email": "neuman+pear@twilio.com", + "role": "Developer" + }, + { + "name": "Anant Narayanan", + "email": "anant@php.net", + "role": "Developer" + } + ], + "description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.", + "homepage": "https://github.com/firebase/php-jwt", + "keywords": [ + "jwt", + "php" + ], + "support": { + "issues": "https://github.com/googleapis/php-jwt/issues", + "source": "https://github.com/googleapis/php-jwt/tree/v7.0.5" + }, + "time": "2026-04-01T20:38:03+00:00" + }, { "name": "fruitcake/php-cors", "version": "v1.4.0", @@ -1276,6 +1407,81 @@ }, "time": "2026-04-21T13:32:11+00:00" }, + { + "name": "laravel/passport", + "version": "v13.7.5", + "source": { + "type": "git", + "url": "https://github.com/laravel/passport.git", + "reference": "90053dc4ba681c076855779250109bb624f961f6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/passport/zipball/90053dc4ba681c076855779250109bb624f961f6", + "reference": "90053dc4ba681c076855779250109bb624f961f6", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-openssl": "*", + "firebase/php-jwt": "^6.4|^7.0", + "illuminate/auth": "^11.35|^12.0|^13.0", + "illuminate/console": "^11.35|^12.0|^13.0", + "illuminate/container": "^11.35|^12.0|^13.0", + "illuminate/contracts": "^11.35|^12.0|^13.0", + "illuminate/cookie": "^11.35|^12.0|^13.0", + "illuminate/database": "^11.35|^12.0|^13.0", + "illuminate/encryption": "^11.35|^12.0|^13.0", + "illuminate/http": "^11.35|^12.0|^13.0", + "illuminate/support": "^11.35|^12.0|^13.0", + "league/oauth2-server": "^9.2", + "php": "^8.2", + "php-http/discovery": "^1.20", + "phpseclib/phpseclib": "^3.0", + "psr/http-factory-implementation": "*", + "symfony/console": "^7.1|^8.0", + "symfony/psr-http-message-bridge": "^7.1|^8.0" + }, + "require-dev": { + "orchestra/testbench": "^9.15|^10.8|^11.0", + "phpstan/phpstan": "^2.0" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Laravel\\Passport\\PassportServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Passport\\": "src/", + "Laravel\\Passport\\Database\\Factories\\": "database/factories/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel Passport provides OAuth2 server support to Laravel.", + "keywords": [ + "laravel", + "oauth", + "passport" + ], + "support": { + "issues": "https://github.com/laravel/passport/issues", + "source": "https://github.com/laravel/passport" + }, + "time": "2026-04-16T14:00:29+00:00" + }, { "name": "laravel/prompts", "version": "v0.3.17", @@ -1465,6 +1671,143 @@ }, "time": "2026-03-17T14:54:13+00:00" }, + { + "name": "lcobucci/clock", + "version": "3.6.0", + "source": { + "type": "git", + "url": "https://github.com/lcobucci/clock.git", + "reference": "4cdd88f761e9be9095ccbedf3e08d61ae216c643" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lcobucci/clock/zipball/4cdd88f761e9be9095ccbedf3e08d61ae216c643", + "reference": "4cdd88f761e9be9095ccbedf3e08d61ae216c643", + "shasum": "" + }, + "require": { + "php": "~8.4.0 || ~8.5.0", + "psr/clock": "^1.0" + }, + "provide": { + "psr/clock-implementation": "1.0" + }, + "require-dev": { + "infection/infection": "^0.32", + "lcobucci/coding-standard": "^12.0", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^2.1", + "phpstan/phpstan-deprecation-rules": "^2.0", + "phpstan/phpstan-phpunit": "^2.0", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^13.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Lcobucci\\Clock\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Luís Cobucci", + "email": "lcobucci@gmail.com" + } + ], + "description": "Yet another clock abstraction", + "support": { + "issues": "https://github.com/lcobucci/clock/issues", + "source": "https://github.com/lcobucci/clock/tree/3.6.0" + }, + "funding": [ + { + "url": "https://github.com/lcobucci", + "type": "github" + }, + { + "url": "https://www.patreon.com/lcobucci", + "type": "patreon" + } + ], + "time": "2026-04-13T21:30:16+00:00" + }, + { + "name": "lcobucci/jwt", + "version": "5.6.0", + "source": { + "type": "git", + "url": "https://github.com/lcobucci/jwt.git", + "reference": "bb3e9f21e4196e8afc41def81ef649c164bca25e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lcobucci/jwt/zipball/bb3e9f21e4196e8afc41def81ef649c164bca25e", + "reference": "bb3e9f21e4196e8afc41def81ef649c164bca25e", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "ext-sodium": "*", + "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "psr/clock": "^1.0" + }, + "require-dev": { + "infection/infection": "^0.29", + "lcobucci/clock": "^3.2", + "lcobucci/coding-standard": "^11.0", + "phpbench/phpbench": "^1.2", + "phpstan/extension-installer": "^1.2", + "phpstan/phpstan": "^1.10.7", + "phpstan/phpstan-deprecation-rules": "^1.1.3", + "phpstan/phpstan-phpunit": "^1.3.10", + "phpstan/phpstan-strict-rules": "^1.5.0", + "phpunit/phpunit": "^11.1" + }, + "suggest": { + "lcobucci/clock": ">= 3.2" + }, + "type": "library", + "autoload": { + "psr-4": { + "Lcobucci\\JWT\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Luís Cobucci", + "email": "lcobucci@gmail.com", + "role": "Developer" + } + ], + "description": "A simple library to work with JSON Web Token and JSON Web Signature", + "keywords": [ + "JWS", + "jwt" + ], + "support": { + "issues": "https://github.com/lcobucci/jwt/issues", + "source": "https://github.com/lcobucci/jwt/tree/5.6.0" + }, + "funding": [ + { + "url": "https://github.com/lcobucci", + "type": "github" + }, + { + "url": "https://www.patreon.com/lcobucci", + "type": "patreon" + } + ], + "time": "2025-10-17T11:30:53+00:00" + }, { "name": "league/commonmark", "version": "2.8.2", @@ -1654,6 +1997,65 @@ ], "time": "2022-12-11T20:36:23+00:00" }, + { + "name": "league/event", + "version": "3.0.3", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/event.git", + "reference": "ec38ff7ea10cad7d99a79ac937fbcffb9334c210" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/event/zipball/ec38ff7ea10cad7d99a79ac937fbcffb9334c210", + "reference": "ec38ff7ea10cad7d99a79ac937fbcffb9334c210", + "shasum": "" + }, + "require": { + "php": ">=7.2.0", + "psr/event-dispatcher": "^1.0" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.16", + "phpstan/phpstan": "^0.12.45", + "phpunit/phpunit": "^8.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "League\\Event\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Frank de Jonge", + "email": "info@frenky.net" + } + ], + "description": "Event package", + "keywords": [ + "emitter", + "event", + "listener" + ], + "support": { + "issues": "https://github.com/thephpleague/event/issues", + "source": "https://github.com/thephpleague/event/tree/3.0.3" + }, + "time": "2024-09-04T16:06:53+00:00" + }, { "name": "league/flysystem", "version": "3.33.0", @@ -1842,6 +2244,102 @@ ], "time": "2024-09-21T08:32:55+00:00" }, + { + "name": "league/oauth2-server", + "version": "9.3.0", + "source": { + "type": "git", + "url": "https://github.com/thephpleague/oauth2-server.git", + "reference": "d8e2f39f645a82b207bbac441694d6e6079357cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thephpleague/oauth2-server/zipball/d8e2f39f645a82b207bbac441694d6e6079357cb", + "reference": "d8e2f39f645a82b207bbac441694d6e6079357cb", + "shasum": "" + }, + "require": { + "defuse/php-encryption": "^2.4", + "ext-json": "*", + "ext-openssl": "*", + "lcobucci/clock": "^2.3 || ^3.0", + "lcobucci/jwt": "^5.0", + "league/event": "^3.0", + "league/uri": "^7.0", + "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", + "psr/http-message": "^2.0", + "psr/http-server-middleware": "^1.0" + }, + "replace": { + "league/oauth2server": "*", + "lncd/oauth2": "*" + }, + "require-dev": { + "laminas/laminas-diactoros": "^3.5", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^1.12|^2.0", + "phpstan/phpstan-deprecation-rules": "^1.1.4|^2.0", + "phpstan/phpstan-phpunit": "^1.3.15|^2.0", + "phpstan/phpstan-strict-rules": "^1.5.2|^2.0", + "phpunit/phpunit": "^10.5|^11.5|^12.0", + "roave/security-advisories": "dev-master", + "slevomat/coding-standard": "^8.14.1", + "squizlabs/php_codesniffer": "^3.8" + }, + "type": "library", + "autoload": { + "psr-4": { + "League\\OAuth2\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Alex Bilbie", + "email": "hello@alexbilbie.com", + "homepage": "http://www.alexbilbie.com", + "role": "Developer" + }, + { + "name": "Andy Millington", + "email": "andrew@noexceptions.io", + "homepage": "https://www.noexceptions.io", + "role": "Developer" + } + ], + "description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.", + "homepage": "https://oauth2.thephpleague.com/", + "keywords": [ + "Authentication", + "api", + "auth", + "authorisation", + "authorization", + "oauth", + "oauth 2", + "oauth 2.0", + "oauth2", + "protect", + "resource", + "secure", + "server" + ], + "support": { + "issues": "https://github.com/thephpleague/oauth2-server/issues", + "source": "https://github.com/thephpleague/oauth2-server/tree/9.3.0" + }, + "funding": [ + { + "url": "https://github.com/sephster", + "type": "github" + } + ], + "time": "2025-11-25T22:51:15+00:00" + }, { "name": "league/uri", "version": "7.8.1", @@ -2535,6 +3033,204 @@ ], "time": "2026-02-16T23:10:27+00:00" }, + { + "name": "paragonie/constant_time_encoding", + "version": "v3.1.3", + "source": { + "type": "git", + "url": "https://github.com/paragonie/constant_time_encoding.git", + "reference": "d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77", + "reference": "d5b01a39b3415c2cd581d3bd3a3575c1ebbd8e77", + "shasum": "" + }, + "require": { + "php": "^8" + }, + "require-dev": { + "infection/infection": "^0", + "nikic/php-fuzzer": "^0", + "phpunit/phpunit": "^9|^10|^11", + "vimeo/psalm": "^4|^5|^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "ParagonIE\\ConstantTime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com", + "role": "Maintainer" + }, + { + "name": "Steve 'Sc00bz' Thomas", + "email": "steve@tobtu.com", + "homepage": "https://www.tobtu.com", + "role": "Original Developer" + } + ], + "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", + "keywords": [ + "base16", + "base32", + "base32_decode", + "base32_encode", + "base64", + "base64_decode", + "base64_encode", + "bin2hex", + "encoding", + "hex", + "hex2bin", + "rfc4648" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/constant_time_encoding/issues", + "source": "https://github.com/paragonie/constant_time_encoding" + }, + "time": "2025-09-24T15:06:41+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, + { + "name": "php-http/discovery", + "version": "1.20.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "82fe4c73ef3363caed49ff8dd1539ba06044910d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/82fe4c73ef3363caed49ff8dd1539ba06044910d", + "reference": "82fe4c73ef3363caed49ff8dd1539ba06044910d", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0|^2.0", + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0", + "zendframework/zend-diactoros": "*" + }, + "provide": { + "php-http/async-client-implementation": "*", + "php-http/client-implementation": "*", + "psr/http-client-implementation": "*", + "psr/http-factory-implementation": "*", + "psr/http-message-implementation": "*" + }, + "require-dev": { + "composer/composer": "^1.0.2|^2.0", + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1 || ^7.3", + "sebastian/comparator": "^3.0.5 || ^4.0.8", + "symfony/phpunit-bridge": "^6.4.4 || ^7.0.1" + }, + "type": "composer-plugin", + "extra": { + "class": "Http\\Discovery\\Composer\\Plugin", + "plugin-optional": true + }, + "autoload": { + "psr-4": { + "Http\\Discovery\\": "src/" + }, + "exclude-from-classmap": [ + "src/Composer/Plugin.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations", + "homepage": "http://php-http.org", + "keywords": [ + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr17", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.20.0" + }, + "time": "2024-10-02T11:20:13+00:00" + }, { "name": "phpoption/phpoption", "version": "1.9.5", @@ -2610,6 +3306,116 @@ ], "time": "2025-12-27T19:41:33+00:00" }, + { + "name": "phpseclib/phpseclib", + "version": "3.0.52", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "2adaefc83df2ec548558307690f376dd7d4f4fce" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/2adaefc83df2ec548558307690f376dd7d4f4fce", + "reference": "2adaefc83df2ec548558307690f376dd7d4f4fce", + "shasum": "" + }, + "require": { + "paragonie/constant_time_encoding": "^1|^2|^3", + "paragonie/random_compat": "^1.4|^2.0|^9.99.99", + "php": ">=5.6.1" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "suggest": { + "ext-dom": "Install the DOM extension to load XML formatted public keys.", + "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", + "ext-libsodium": "SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.", + "ext-mcrypt": "Install the Mcrypt extension in order to speed up a few other cryptographic operations.", + "ext-openssl": "Install the OpenSSL extension in order to speed up a wide variety of cryptographic operations." + }, + "type": "library", + "autoload": { + "files": [ + "phpseclib/bootstrap.php" + ], + "psr-4": { + "phpseclib3\\": "phpseclib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jim Wigginton", + "email": "terrafrost@php.net", + "role": "Lead Developer" + }, + { + "name": "Patrick Monnerat", + "email": "pm@datasphere.ch", + "role": "Developer" + }, + { + "name": "Andreas Fischer", + "email": "bantu@phpbb.com", + "role": "Developer" + }, + { + "name": "Hans-Jürgen Petrich", + "email": "petrich@tronic-media.com", + "role": "Developer" + }, + { + "name": "Graham Campbell", + "email": "graham@alt-three.com", + "role": "Developer" + } + ], + "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", + "homepage": "http://phpseclib.sourceforge.net", + "keywords": [ + "BigInteger", + "aes", + "asn.1", + "asn1", + "blowfish", + "crypto", + "cryptography", + "encryption", + "rsa", + "security", + "sftp", + "signature", + "signing", + "ssh", + "twofish", + "x.509", + "x509" + ], + "support": { + "issues": "https://github.com/phpseclib/phpseclib/issues", + "source": "https://github.com/phpseclib/phpseclib/tree/3.0.52" + }, + "funding": [ + { + "url": "https://github.com/terrafrost", + "type": "github" + }, + { + "url": "https://www.patreon.com/phpseclib", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpseclib/phpseclib", + "type": "tidelift" + } + ], + "time": "2026-04-27T07:02:15+00:00" + }, { "name": "psr/clock", "version": "1.0.0", @@ -2921,6 +3727,119 @@ }, "time": "2023-04-04T09:54:51+00:00" }, + { + "name": "psr/http-server-handler", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-handler.git", + "reference": "84c4fb66179be4caaf8e97bd239203245302e7d4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-handler/zipball/84c4fb66179be4caaf8e97bd239203245302e7d4", + "reference": "84c4fb66179be4caaf8e97bd239203245302e7d4", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side request handler", + "keywords": [ + "handler", + "http", + "http-interop", + "psr", + "psr-15", + "psr-7", + "request", + "response", + "server" + ], + "support": { + "source": "https://github.com/php-fig/http-server-handler/tree/1.0.2" + }, + "time": "2023-04-10T20:06:20+00:00" + }, + { + "name": "psr/http-server-middleware", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-server-middleware.git", + "reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-server-middleware/zipball/c1481f747daaa6a0782775cd6a8c26a1bf4a3829", + "reference": "c1481f747daaa6a0782775cd6a8c26a1bf4a3829", + "shasum": "" + }, + "require": { + "php": ">=7.0", + "psr/http-message": "^1.0 || ^2.0", + "psr/http-server-handler": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Server\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP server-side middleware", + "keywords": [ + "http", + "http-interop", + "middleware", + "psr", + "psr-15", + "psr-7", + "request", + "response" + ], + "support": { + "issues": "https://github.com/php-fig/http-server-middleware/issues", + "source": "https://github.com/php-fig/http-server-middleware/tree/1.0.2" + }, + "time": "2023-04-11T06:14:47+00:00" + }, { "name": "psr/log", "version": "3.0.2", @@ -3299,6 +4218,154 @@ }, "time": "2025-12-14T04:43:48+00:00" }, + { + "name": "spatie/laravel-package-tools", + "version": "1.93.0", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-package-tools.git", + "reference": "0d097bce95b2bf6802fb1d83e1e753b0f5a948e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/0d097bce95b2bf6802fb1d83e1e753b0f5a948e7", + "reference": "0d097bce95b2bf6802fb1d83e1e753b0f5a948e7", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^10.0|^11.0|^12.0|^13.0", + "php": "^8.1" + }, + "require-dev": { + "mockery/mockery": "^1.5", + "orchestra/testbench": "^8.0|^9.2|^10.0|^11.0", + "pestphp/pest": "^2.1|^3.1|^4.0", + "phpunit/php-code-coverage": "^10.0|^11.0|^12.0", + "phpunit/phpunit": "^10.5|^11.5|^12.5", + "spatie/pest-plugin-test-time": "^2.2|^3.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Spatie\\LaravelPackageTools\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "role": "Developer" + } + ], + "description": "Tools for creating Laravel packages", + "homepage": "https://github.com/spatie/laravel-package-tools", + "keywords": [ + "laravel-package-tools", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-package-tools/issues", + "source": "https://github.com/spatie/laravel-package-tools/tree/1.93.0" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2026-02-21T12:49:54+00:00" + }, + { + "name": "spatie/laravel-permission", + "version": "7.4.1", + "source": { + "type": "git", + "url": "https://github.com/spatie/laravel-permission.git", + "reference": "ef42ecb781e5534d368a3853fa161e420ad51397" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/laravel-permission/zipball/ef42ecb781e5534d368a3853fa161e420ad51397", + "reference": "ef42ecb781e5534d368a3853fa161e420ad51397", + "shasum": "" + }, + "require": { + "illuminate/auth": "^12.0|^13.0", + "illuminate/container": "^12.0|^13.0", + "illuminate/contracts": "^12.0|^13.0", + "illuminate/database": "^12.0|^13.0", + "php": "^8.3", + "spatie/laravel-package-tools": "^1.0" + }, + "require-dev": { + "larastan/larastan": "^3.9", + "laravel/passport": "^13.0", + "laravel/pint": "^1.0", + "orchestra/testbench": "^10.0|^11.0", + "pestphp/pest": "^3.0|^4.0", + "pestphp/pest-plugin-laravel": "^3.0|^4.1", + "phpstan/phpstan": "^2.1" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Spatie\\Permission\\PermissionServiceProvider" + ] + }, + "branch-alias": { + "dev-main": "7.x-dev", + "dev-master": "7.x-dev" + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Spatie\\Permission\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://spatie.be", + "role": "Developer" + } + ], + "description": "Permission handling for Laravel 12 and up", + "homepage": "https://github.com/spatie/laravel-permission", + "keywords": [ + "acl", + "laravel", + "permission", + "permissions", + "rbac", + "roles", + "security", + "spatie" + ], + "support": { + "issues": "https://github.com/spatie/laravel-permission/issues", + "source": "https://github.com/spatie/laravel-permission/tree/7.4.1" + }, + "funding": [ + { + "url": "https://github.com/spatie", + "type": "github" + } + ], + "time": "2026-04-29T07:59:45+00:00" + }, { "name": "symfony/clock", "version": "v8.0.8", @@ -5076,6 +6143,93 @@ ], "time": "2026-03-30T15:14:47+00:00" }, + { + "name": "symfony/psr-http-message-bridge", + "version": "v8.0.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/psr-http-message-bridge.git", + "reference": "94facc221260c1d5f20e31ee43cd6c6a824b4a19" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/94facc221260c1d5f20e31ee43cd6c6a824b4a19", + "reference": "94facc221260c1d5f20e31ee43cd6c6a824b4a19", + "shasum": "" + }, + "require": { + "php": ">=8.4", + "psr/http-message": "^1.0|^2.0", + "symfony/http-foundation": "^7.4|^8.0" + }, + "conflict": { + "php-http/discovery": "<1.15" + }, + "require-dev": { + "nyholm/psr7": "^1.1", + "php-http/discovery": "^1.15", + "psr/log": "^1.1.4|^2|^3", + "symfony/browser-kit": "^7.4|^8.0", + "symfony/config": "^7.4|^8.0", + "symfony/event-dispatcher": "^7.4|^8.0", + "symfony/framework-bundle": "^7.4|^8.0", + "symfony/http-kernel": "^7.4|^8.0", + "symfony/runtime": "^7.4|^8.0" + }, + "type": "symfony-bridge", + "autoload": { + "psr-4": { + "Symfony\\Bridge\\PsrHttpMessage\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "PSR HTTP message bridge", + "homepage": "https://symfony.com", + "keywords": [ + "http", + "http-message", + "psr-17", + "psr-7" + ], + "support": { + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v8.0.8" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2026-03-30T15:14:47+00:00" + }, { "name": "symfony/routing", "version": "v8.0.8", @@ -9091,5 +10245,5 @@ "php": "^8.3" }, "platform-dev": {}, - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.9.0" } diff --git a/backend/config/app.php b/backend/config/app.php old mode 100644 new mode 100755 diff --git a/backend/config/auth.php b/backend/config/auth.php old mode 100644 new mode 100755 index d7568ff1..63cce897 --- a/backend/config/auth.php +++ b/backend/config/auth.php @@ -1,5 +1,6 @@ 'session', 'provider' => 'users', ], + 'api' => [ + 'driver' => 'passport', + 'provider' => 'users', + ], + 'expert' => [ + 'driver' => 'session', + 'provider' => 'experts', + ] ], /* @@ -66,6 +75,10 @@ return [ 'driver' => 'eloquent', 'model' => env('AUTH_MODEL', User::class), ], + 'experts' => [ + 'driver' => 'eloquent', + 'model' => env('AUTH_MODEL', Expert::class), + ], // 'users' => [ // 'driver' => 'database', diff --git a/backend/config/cache.php b/backend/config/cache.php old mode 100644 new mode 100755 diff --git a/backend/config/cors.php b/backend/config/cors.php new file mode 100755 index 00000000..a76728a2 --- /dev/null +++ b/backend/config/cors.php @@ -0,0 +1,34 @@ + ['*'], + + 'allowed_methods' => ['*'], + + 'allowed_origins' => ['*'], + + 'allowed_origins_patterns' => [], + + 'allowed_headers' => ['*'], + + 'exposed_headers' => [], + + 'max_age' => 0, + + 'supports_credentials' => true, + +]; diff --git a/backend/config/database.php b/backend/config/database.php old mode 100644 new mode 100755 diff --git a/backend/config/fib.php b/backend/config/fib.php new file mode 100755 index 00000000..1ddfc3d4 --- /dev/null +++ b/backend/config/fib.php @@ -0,0 +1,25 @@ + [ + 'url' => env('FIB_AUTHORIZATION_URL'), + 'client_id' => env('FIB_CLIENT_ID'), + 'client_secret' => env('FIB_CLIENT_SECRET'), + ], + + 'createPayment' => [ + 'url' => env('FIB_CREATE_PAYMENT_URL'), + ], + + 'checkPaymentStatus' => [ + 'url' => env('FIB_CHECK_PAYMENT_STATUS_URL'), + ], + + 'cancelPayment' => [ + 'url' => env('FIB_CANCEL_PAYMENT_URL'), + ], + + 'refund' => [ + 'url' => env('FIB_REFUND_URL'), + ], +]; diff --git a/backend/config/filesystems.php b/backend/config/filesystems.php old mode 100644 new mode 100755 diff --git a/backend/config/logging.php b/backend/config/logging.php old mode 100644 new mode 100755 index b09cb25d..ee09ba9e --- a/backend/config/logging.php +++ b/backend/config/logging.php @@ -127,6 +127,12 @@ return [ 'path' => storage_path('logs/laravel.log'), ], + 'fib_authorization' => [ + 'driver' => 'single', + 'path' => storage_path('logs/fib/authorization.log'), + 'level' => 'error', + ], + ], ]; diff --git a/backend/config/mail.php b/backend/config/mail.php old mode 100644 new mode 100755 diff --git a/backend/config/passport.php b/backend/config/passport.php new file mode 100755 index 00000000..aed43589 --- /dev/null +++ b/backend/config/passport.php @@ -0,0 +1,48 @@ + 'web', + + 'middleware' => [], + + /* + |-------------------------------------------------------------------------- + | Encryption Keys + |-------------------------------------------------------------------------- + | + | Passport uses encryption keys while generating secure access tokens for + | your application. By default, the keys are stored as local files but + | can be set via environment variables when that is more convenient. + | + */ + + 'private_key' => env('PASSPORT_PRIVATE_KEY'), + + 'public_key' => env('PASSPORT_PUBLIC_KEY'), + + /* + |-------------------------------------------------------------------------- + | Passport Database Connection + |-------------------------------------------------------------------------- + | + | By default, Passport's models will utilize your application's default + | database connection. If you wish to use a different connection you + | may specify the configured name of the database connection here. + | + */ + + 'connection' => env('PASSPORT_CONNECTION'), + +]; diff --git a/backend/config/permission.php b/backend/config/permission.php new file mode 100755 index 00000000..8f1f452d --- /dev/null +++ b/backend/config/permission.php @@ -0,0 +1,219 @@ + [ + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * Eloquent model should be used to retrieve your permissions. Of course, it + * is often just the "Permission" model but you may use whatever you like. + * + * The model you want to use as a Permission model needs to implement the + * `Spatie\Permission\Contracts\Permission` contract. + */ + + 'permission' => Permission::class, + + /* + * When using the "HasRoles" trait from this package, we need to know which + * Eloquent model should be used to retrieve your roles. Of course, it + * is often just the "Role" model but you may use whatever you like. + * + * The model you want to use as a Role model needs to implement the + * `Spatie\Permission\Contracts\Role` contract. + */ + + 'role' => Role::class, + + /* + * When using the "Teams" feature from this package, we need to know which + * Eloquent model should be used to retrieve your teams. Of course, it + * is often just the "Team" model but you may use whatever you like. + */ + 'team' => null, + + /* + * When using the "HasModels" trait and passing raw IDs to syncModels, + * attachModels, or detachModels, this model class will be used to + * resolve those IDs. If null, defaults to the guard's model. + */ + 'default_model' => null, + ], + + 'table_names' => [ + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your roles. We have chosen a basic + * default value but you may easily change it to any table you like. + */ + + 'roles' => 'roles', + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * table should be used to retrieve your permissions. We have chosen a basic + * default value but you may easily change it to any table you like. + */ + + 'permissions' => 'permissions', + + /* + * When using the "HasPermissions" trait from this package, we need to know which + * table should be used to retrieve your models permissions. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'model_has_permissions' => 'model_has_permissions', + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your models roles. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'model_has_roles' => 'model_has_roles', + + /* + * When using the "HasRoles" trait from this package, we need to know which + * table should be used to retrieve your roles permissions. We have chosen a + * basic default value but you may easily change it to any table you like. + */ + + 'role_has_permissions' => 'role_has_permissions', + ], + + 'column_names' => [ + /* + * Change this if you want to name the related pivots other than defaults + */ + 'role_pivot_key' => null, // default 'role_id', + 'permission_pivot_key' => null, // default 'permission_id', + + /* + * Change this if you want to name the related model primary key other than + * `model_id`. + * + * For example, this would be nice if your primary keys are all UUIDs. In + * that case, name this `model_uuid`. + */ + + 'model_morph_key' => 'model_id', + + /* + * Change this if you want to use the teams feature and your related model's + * foreign key is other than `team_id`. + */ + + 'team_foreign_key' => 'team_id', + ], + + /* + * When set to true, the method for checking permissions will be registered on the gate. + * Set this to false if you want to implement custom logic for checking permissions. + */ + + 'register_permission_check_method' => true, + + /* + * When set to true, Laravel\Octane\Events\OperationTerminated event listener will be registered + * this will refresh permissions on every TickTerminated, TaskTerminated and RequestTerminated + * NOTE: This should not be needed in most cases, but an Octane/Vapor combination benefited from it. + */ + 'register_octane_reset_listener' => false, + + /* + * Events will fire when a role or permission is assigned/unassigned: + * \Spatie\Permission\Events\RoleAttachedEvent + * \Spatie\Permission\Events\RoleDetachedEvent + * \Spatie\Permission\Events\PermissionAttachedEvent + * \Spatie\Permission\Events\PermissionDetachedEvent + * + * To enable, set to true, and then create listeners to watch these events. + */ + 'events_enabled' => false, + + /* + * Teams Feature. + * When set to true the package implements teams using the 'team_foreign_key'. + * If you want the migrations to register the 'team_foreign_key', you must + * set this to true before doing the migration. + * If you already did the migration then you must make a new migration to also + * add 'team_foreign_key' to 'roles', 'model_has_roles', and 'model_has_permissions' + * (view the latest version of this package's migration file) + */ + + 'teams' => false, + + /* + * The class to use to resolve the permissions team id + */ + 'team_resolver' => DefaultTeamResolver::class, + + /* + * Passport Client Credentials Grant + * When set to true the package will use Passports Client to check permissions + */ + + 'use_passport_client_credentials' => false, + + /* + * When set to true, the required permission names are added to exception messages. + * This could be considered an information leak in some contexts, so the default + * setting is false here for optimum safety. + */ + + 'display_permission_in_exception' => false, + + /* + * When set to true, the required role names are added to exception messages. + * This could be considered an information leak in some contexts, so the default + * setting is false here for optimum safety. + */ + + 'display_role_in_exception' => false, + + /* + * By default wildcard permission lookups are disabled. + * See documentation to understand supported syntax. + */ + + 'enable_wildcard_permission' => false, + + /* + * The class to use for interpreting wildcard permissions. + * If you need to modify delimiters, override the class and specify its name here. + */ + // 'wildcard_permission' => Spatie\Permission\WildcardPermission::class, + + /* Cache-specific settings */ + + 'cache' => [ + + /* + * By default all permissions are cached for 24 hours to speed up performance. + * When permissions or roles are updated the cache is flushed automatically. + */ + + 'expiration_time' => DateInterval::createFromDateString('24 hours'), + + /* + * The cache key used to store all permissions. + */ + + 'key' => 'spatie.permission.cache', + + /* + * You may optionally indicate a specific cache driver to use for permission and + * role caching using any of the `store` drivers listed in the cache.php config + * file. Using 'default' here means to use the `default` set in cache.php. + */ + + 'store' => 'default', + ], +]; diff --git a/backend/config/queue.php b/backend/config/queue.php old mode 100644 new mode 100755 diff --git a/backend/config/services.php b/backend/config/services.php old mode 100644 new mode 100755 diff --git a/backend/config/session.php b/backend/config/session.php old mode 100644 new mode 100755 diff --git a/backend/database/.gitignore b/backend/database/.gitignore old mode 100644 new mode 100755 diff --git a/backend/database/factories/BusinessTypeFactory.php b/backend/database/factories/BusinessTypeFactory.php new file mode 100644 index 00000000..e4f420cb --- /dev/null +++ b/backend/database/factories/BusinessTypeFactory.php @@ -0,0 +1,24 @@ + + */ +class BusinessTypeFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/CityFactory.php b/backend/database/factories/CityFactory.php new file mode 100755 index 00000000..e658dee8 --- /dev/null +++ b/backend/database/factories/CityFactory.php @@ -0,0 +1,24 @@ + + */ +class CityFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/DocumentFactory.php b/backend/database/factories/DocumentFactory.php new file mode 100755 index 00000000..bb26de44 --- /dev/null +++ b/backend/database/factories/DocumentFactory.php @@ -0,0 +1,24 @@ + + */ +class DocumentFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/ExpertFactory.php b/backend/database/factories/ExpertFactory.php new file mode 100755 index 00000000..6daae3d7 --- /dev/null +++ b/backend/database/factories/ExpertFactory.php @@ -0,0 +1,24 @@ + + */ +class ExpertFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/FibTransactionFactory.php b/backend/database/factories/FibTransactionFactory.php new file mode 100644 index 00000000..5fc97df6 --- /dev/null +++ b/backend/database/factories/FibTransactionFactory.php @@ -0,0 +1,24 @@ + + */ +class FibTransactionFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/FibTransactionStatusFactory.php b/backend/database/factories/FibTransactionStatusFactory.php new file mode 100644 index 00000000..94676e04 --- /dev/null +++ b/backend/database/factories/FibTransactionStatusFactory.php @@ -0,0 +1,24 @@ + + */ +class FibTransactionStatusFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/PaymentFactory.php b/backend/database/factories/PaymentFactory.php new file mode 100644 index 00000000..8bfd4911 --- /dev/null +++ b/backend/database/factories/PaymentFactory.php @@ -0,0 +1,24 @@ + + */ +class PaymentFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/PaymentStatusFactory.php b/backend/database/factories/PaymentStatusFactory.php new file mode 100644 index 00000000..390010db --- /dev/null +++ b/backend/database/factories/PaymentStatusFactory.php @@ -0,0 +1,24 @@ + + */ +class PaymentStatusFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/ProvinceFactory.php b/backend/database/factories/ProvinceFactory.php new file mode 100755 index 00000000..3b869034 --- /dev/null +++ b/backend/database/factories/ProvinceFactory.php @@ -0,0 +1,24 @@ + + */ +class ProvinceFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/TransactionFactory.php b/backend/database/factories/TransactionFactory.php new file mode 100644 index 00000000..9f46bf36 --- /dev/null +++ b/backend/database/factories/TransactionFactory.php @@ -0,0 +1,24 @@ + + */ +class TransactionFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/factories/UserFactory.php b/backend/database/factories/UserFactory.php old mode 100644 new mode 100755 index c4ceb074..b3301b8b --- a/backend/database/factories/UserFactory.php +++ b/backend/database/factories/UserFactory.php @@ -25,7 +25,7 @@ class UserFactory extends Factory public function definition(): array { return [ - 'name' => fake()->name(), + 'username' => fake()->name(), 'email' => fake()->unique()->safeEmail(), 'email_verified_at' => now(), 'password' => static::$password ??= Hash::make('password'), diff --git a/backend/database/factories/UserGatewayFactory.php b/backend/database/factories/UserGatewayFactory.php new file mode 100644 index 00000000..46062b0f --- /dev/null +++ b/backend/database/factories/UserGatewayFactory.php @@ -0,0 +1,24 @@ + + */ +class UserGatewayFactory extends Factory +{ + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + // + ]; + } +} diff --git a/backend/database/migrations/0001_01_00_000000_create_provinces_table.php b/backend/database/migrations/0001_01_00_000000_create_provinces_table.php new file mode 100755 index 00000000..3a3f6901 --- /dev/null +++ b/backend/database/migrations/0001_01_00_000000_create_provinces_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('provinces'); + } +}; diff --git a/backend/database/migrations/0001_01_00_000001_create_cities_table.php b/backend/database/migrations/0001_01_00_000001_create_cities_table.php new file mode 100755 index 00000000..4cf721fc --- /dev/null +++ b/backend/database/migrations/0001_01_00_000001_create_cities_table.php @@ -0,0 +1,29 @@ +id(); + $table->string('name'); + $table->foreignId('province_id')->constrained('provinces'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('cities'); + } +}; diff --git a/backend/database/migrations/0001_01_01_000000_create_users_table.php b/backend/database/migrations/0001_01_01_000000_create_users_table.php old mode 100644 new mode 100755 index 05fb5d9e..124ca19a --- a/backend/database/migrations/0001_01_01_000000_create_users_table.php +++ b/backend/database/migrations/0001_01_01_000000_create_users_table.php @@ -13,20 +13,25 @@ return new class extends Migration { Schema::create('users', function (Blueprint $table) { $table->id(); - $table->string('name'); + $table->string('username'); + $table->string('first_name')->nullable(); + $table->string('last_name')->nullable(); $table->string('email')->unique(); - $table->timestamp('email_verified_at')->nullable(); $table->string('password'); - $table->rememberToken(); + $table->tinyInteger('kyc_status')->default(0); + $table->string('national_id')->nullable(); + $table->string('address')->nullable(); + $table->string('postal_code')->nullable(); + $table->string('phone_number')->nullable(); + $table->date('birth_date')->nullable(); + $table->foreignId('province_id')->nullable()->constrained('provinces'); + $table->string('province_name')->nullable(); + $table->foreignId('city_id')->nullable()->constrained('cities'); + $table->string('city_name')->nullable(); + $table->tinyInteger('authority_level')->default(0); $table->timestamps(); }); - Schema::create('password_reset_tokens', function (Blueprint $table) { - $table->string('email')->primary(); - $table->string('token'); - $table->timestamp('created_at')->nullable(); - }); - Schema::create('sessions', function (Blueprint $table) { $table->string('id')->primary(); $table->foreignId('user_id')->nullable()->index(); @@ -43,7 +48,6 @@ return new class extends Migration public function down(): void { Schema::dropIfExists('users'); - Schema::dropIfExists('password_reset_tokens'); Schema::dropIfExists('sessions'); } }; diff --git a/backend/database/migrations/0001_01_01_000001_create_cache_table.php b/backend/database/migrations/0001_01_01_000001_create_cache_table.php old mode 100644 new mode 100755 diff --git a/backend/database/migrations/0001_01_01_000002_create_jobs_table.php b/backend/database/migrations/0001_01_01_000002_create_jobs_table.php old mode 100644 new mode 100755 diff --git a/backend/database/migrations/2026_04_27_122415_create_oauth_auth_codes_table.php b/backend/database/migrations/2026_04_27_122415_create_oauth_auth_codes_table.php new file mode 100755 index 00000000..c700b50e --- /dev/null +++ b/backend/database/migrations/2026_04_27_122415_create_oauth_auth_codes_table.php @@ -0,0 +1,39 @@ +char('id', 80)->primary(); + $table->foreignId('user_id')->index(); + $table->foreignUuid('client_id'); + $table->text('scopes')->nullable(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_auth_codes'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/backend/database/migrations/2026_04_27_122416_create_oauth_access_tokens_table.php b/backend/database/migrations/2026_04_27_122416_create_oauth_access_tokens_table.php new file mode 100755 index 00000000..3e50f7f7 --- /dev/null +++ b/backend/database/migrations/2026_04_27_122416_create_oauth_access_tokens_table.php @@ -0,0 +1,41 @@ +char('id', 80)->primary(); + $table->foreignId('user_id')->nullable()->index(); + $table->foreignUuid('client_id'); + $table->string('name')->nullable(); + $table->text('scopes')->nullable(); + $table->boolean('revoked'); + $table->timestamps(); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_access_tokens'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/backend/database/migrations/2026_04_27_122417_create_oauth_refresh_tokens_table.php b/backend/database/migrations/2026_04_27_122417_create_oauth_refresh_tokens_table.php new file mode 100755 index 00000000..afb3c55c --- /dev/null +++ b/backend/database/migrations/2026_04_27_122417_create_oauth_refresh_tokens_table.php @@ -0,0 +1,37 @@ +char('id', 80)->primary(); + $table->char('access_token_id', 80)->index(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_refresh_tokens'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/backend/database/migrations/2026_04_27_122418_create_oauth_clients_table.php b/backend/database/migrations/2026_04_27_122418_create_oauth_clients_table.php new file mode 100755 index 00000000..9794dc86 --- /dev/null +++ b/backend/database/migrations/2026_04_27_122418_create_oauth_clients_table.php @@ -0,0 +1,42 @@ +uuid('id')->primary(); + $table->nullableMorphs('owner'); + $table->string('name'); + $table->string('secret')->nullable(); + $table->string('provider')->nullable(); + $table->text('redirect_uris'); + $table->text('grant_types'); + $table->boolean('revoked'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_clients'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/backend/database/migrations/2026_04_27_122419_create_oauth_device_codes_table.php b/backend/database/migrations/2026_04_27_122419_create_oauth_device_codes_table.php new file mode 100755 index 00000000..ea078319 --- /dev/null +++ b/backend/database/migrations/2026_04_27_122419_create_oauth_device_codes_table.php @@ -0,0 +1,42 @@ +char('id', 80)->primary(); + $table->foreignId('user_id')->nullable()->index(); + $table->foreignUuid('client_id')->index(); + $table->char('user_code', 8)->unique(); + $table->text('scopes'); + $table->boolean('revoked'); + $table->dateTime('user_approved_at')->nullable(); + $table->dateTime('last_polled_at')->nullable(); + $table->dateTime('expires_at')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('oauth_device_codes'); + } + + /** + * Get the migration connection name. + */ + public function getConnection(): ?string + { + return $this->connection ?? config('passport.connection'); + } +}; diff --git a/backend/database/migrations/2026_05_10_123913_create_permission_tables.php b/backend/database/migrations/2026_05_10_123913_create_permission_tables.php new file mode 100755 index 00000000..89862751 --- /dev/null +++ b/backend/database/migrations/2026_05_10_123913_create_permission_tables.php @@ -0,0 +1,137 @@ +id(); // permission id + $table->string('name'); + $table->string('guard_name'); + $table->timestamps(); + + $table->unique(['name', 'guard_name']); + }); + + /** + * See `docs/prerequisites.md` for suggested lengths on 'name' and 'guard_name' if "1071 Specified key was too long" errors are encountered. + */ + Schema::create($tableNames['roles'], static function (Blueprint $table) use ($teams, $columnNames) { + $table->id(); // role id + if ($teams || config('permission.testing')) { // permission.testing is a fix for sqlite testing + $table->unsignedBigInteger($columnNames['team_foreign_key'])->nullable(); + $table->index($columnNames['team_foreign_key'], 'roles_team_foreign_key_index'); + } + $table->string('name'); + $table->string('guard_name'); + $table->timestamps(); + if ($teams || config('permission.testing')) { + $table->unique([$columnNames['team_foreign_key'], 'name', 'guard_name']); + } else { + $table->unique(['name', 'guard_name']); + } + }); + + Schema::create($tableNames['model_has_permissions'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotPermission, $teams) { + $table->unsignedBigInteger($pivotPermission); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index'); + + $table->foreign($pivotPermission) + ->references('id') // permission id + ->on($tableNames['permissions']) + ->cascadeOnDelete(); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_permissions_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], $pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } else { + $table->primary([$pivotPermission, $columnNames['model_morph_key'], 'model_type'], + 'model_has_permissions_permission_model_type_primary'); + } + }); + + Schema::create($tableNames['model_has_roles'], static function (Blueprint $table) use ($tableNames, $columnNames, $pivotRole, $teams) { + $table->unsignedBigInteger($pivotRole); + + $table->string('model_type'); + $table->unsignedBigInteger($columnNames['model_morph_key']); + $table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index'); + + $table->foreign($pivotRole) + ->references('id') // role id + ->on($tableNames['roles']) + ->cascadeOnDelete(); + if ($teams) { + $table->unsignedBigInteger($columnNames['team_foreign_key']); + $table->index($columnNames['team_foreign_key'], 'model_has_roles_team_foreign_key_index'); + + $table->primary([$columnNames['team_foreign_key'], $pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } else { + $table->primary([$pivotRole, $columnNames['model_morph_key'], 'model_type'], + 'model_has_roles_role_model_type_primary'); + } + }); + + Schema::create($tableNames['role_has_permissions'], static function (Blueprint $table) use ($tableNames, $pivotRole, $pivotPermission) { + $table->unsignedBigInteger($pivotPermission); + $table->unsignedBigInteger($pivotRole); + + $table->foreign($pivotPermission) + ->references('id') // permission id + ->on($tableNames['permissions']) + ->cascadeOnDelete(); + + $table->foreign($pivotRole) + ->references('id') // role id + ->on($tableNames['roles']) + ->cascadeOnDelete(); + + $table->primary([$pivotPermission, $pivotRole], 'role_has_permissions_permission_id_role_id_primary'); + }); + + app('cache') + ->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null) + ->forget(config('permission.cache.key')); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + $tableNames = config('permission.table_names'); + + throw_if(empty($tableNames), 'Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.'); + + Schema::dropIfExists($tableNames['role_has_permissions']); + Schema::dropIfExists($tableNames['model_has_roles']); + Schema::dropIfExists($tableNames['model_has_permissions']); + Schema::dropIfExists($tableNames['roles']); + Schema::dropIfExists($tableNames['permissions']); + } +}; diff --git a/backend/database/migrations/2026_05_12_053258_create_documents_table.php b/backend/database/migrations/2026_05_12_053258_create_documents_table.php new file mode 100755 index 00000000..8bcc6ba1 --- /dev/null +++ b/backend/database/migrations/2026_05_12_053258_create_documents_table.php @@ -0,0 +1,30 @@ +id(); + $table->morphs('documentable'); + $table->string('title'); + $table->string('url'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('documents'); + } +}; diff --git a/backend/database/migrations/2026_05_12_074230_create_experts_table.php b/backend/database/migrations/2026_05_12_074230_create_experts_table.php new file mode 100755 index 00000000..de3673dd --- /dev/null +++ b/backend/database/migrations/2026_05_12_074230_create_experts_table.php @@ -0,0 +1,38 @@ +id(); + $table->string('username'); + $table->string('first_name')->nullable(); + $table->string('last_name')->nullable(); + $table->string('email')->unique(); + $table->string('password'); + $table->string('national_id')->nullable(); + $table->string('phone_number')->nullable(); + $table->foreignId('province_id')->nullable()->constrained('provinces'); + $table->string('province_name')->nullable(); + $table->foreignId('city_id')->nullable()->constrained('cities'); + $table->string('city_name')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('experts'); + } +}; diff --git a/backend/database/migrations/2026_05_13_054404_add_column_to_users_table.php b/backend/database/migrations/2026_05_13_054404_add_column_to_users_table.php new file mode 100755 index 00000000..dcc326de --- /dev/null +++ b/backend/database/migrations/2026_05_13_054404_add_column_to_users_table.php @@ -0,0 +1,28 @@ +string('kyc_reject_reason')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('kyc_reject_reason'); + }); + } +}; diff --git a/backend/database/migrations/2026_05_17_053830_create_payment_statuses_table.php b/backend/database/migrations/2026_05_17_053830_create_payment_statuses_table.php new file mode 100644 index 00000000..754a8790 --- /dev/null +++ b/backend/database/migrations/2026_05_17_053830_create_payment_statuses_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('payment_statuses'); + } +}; diff --git a/backend/database/migrations/2026_05_17_053831_create_business_types_table.php b/backend/database/migrations/2026_05_17_053831_create_business_types_table.php new file mode 100644 index 00000000..61e834f5 --- /dev/null +++ b/backend/database/migrations/2026_05_17_053831_create_business_types_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('business_types'); + } +}; diff --git a/backend/database/migrations/2026_05_17_053832_create_user_gateways_table.php b/backend/database/migrations/2026_05_17_053832_create_user_gateways_table.php new file mode 100644 index 00000000..d72d530b --- /dev/null +++ b/backend/database/migrations/2026_05_17_053832_create_user_gateways_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignId('user_id')->constrained('users'); + $table->string('username'); + $table->string('name'); + $table->string('domain'); + $table->string('tax_id'); + $table->string('bank_name'); + $table->string('account_holder'); + $table->string('logo')->nullable(); + $table->string('iban'); + $table->foreignId('business_type_id')->constrained('business_types'); + $table->string('business_type_name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('user_gateways'); + } +}; diff --git a/backend/database/migrations/2026_05_17_053833_create_payments_table.php b/backend/database/migrations/2026_05_17_053833_create_payments_table.php new file mode 100644 index 00000000..815bfa82 --- /dev/null +++ b/backend/database/migrations/2026_05_17_053833_create_payments_table.php @@ -0,0 +1,38 @@ +id(); + $table->foreignId('user_id')->constrained('users'); + $table->string('username'); + $table->uuid('track_id'); + $table->string('amount'); + $table->string('currency'); + $table->string('callback_url'); + $table->dateTime('expires_at'); + $table->foreignId('status_id')->constrained('payment_statuses'); + $table->string('status_name'); + $table->ipAddress('ip'); + $table->foreignId('user_gateway_id')->constrained('user_gateways'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('payments'); + } +}; diff --git a/backend/database/migrations/2026_05_18_095610_create_transactions_table.php b/backend/database/migrations/2026_05_18_095610_create_transactions_table.php new file mode 100644 index 00000000..0ffccd66 --- /dev/null +++ b/backend/database/migrations/2026_05_18_095610_create_transactions_table.php @@ -0,0 +1,36 @@ +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'); + } +}; diff --git a/backend/database/migrations/2026_05_18_104523_create_fib_transaction_statuses_table.php b/backend/database/migrations/2026_05_18_104523_create_fib_transaction_statuses_table.php new file mode 100644 index 00000000..f984ce18 --- /dev/null +++ b/backend/database/migrations/2026_05_18_104523_create_fib_transaction_statuses_table.php @@ -0,0 +1,28 @@ +id(); + $table->string('name'); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('fib_transaction_statuses'); + } +}; diff --git a/backend/database/migrations/2026_05_18_104524_create_fib_transactions_table.php b/backend/database/migrations/2026_05_18_104524_create_fib_transactions_table.php new file mode 100644 index 00000000..2b346264 --- /dev/null +++ b/backend/database/migrations/2026_05_18_104524_create_fib_transactions_table.php @@ -0,0 +1,44 @@ +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'); + } +}; diff --git a/backend/database/migrations/2026_06_01_062350_create_password_reset_otps_table.php b/backend/database/migrations/2026_06_01_062350_create_password_reset_otps_table.php new file mode 100755 index 00000000..2b229b8e --- /dev/null +++ b/backend/database/migrations/2026_06_01_062350_create_password_reset_otps_table.php @@ -0,0 +1,30 @@ +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'); + } +}; diff --git a/backend/database/seeders/BusinessTypeSeeder.php b/backend/database/seeders/BusinessTypeSeeder.php new file mode 100644 index 00000000..01726e9f --- /dev/null +++ b/backend/database/seeders/BusinessTypeSeeder.php @@ -0,0 +1,34 @@ +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()], + ]); + } +} diff --git a/backend/database/seeders/CitySeeder.php b/backend/database/seeders/CitySeeder.php new file mode 100755 index 00000000..83f4ea9a --- /dev/null +++ b/backend/database/seeders/CitySeeder.php @@ -0,0 +1,137 @@ +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()], + ]); + } +} diff --git a/backend/database/seeders/DatabaseSeeder.php b/backend/database/seeders/DatabaseSeeder.php old mode 100644 new mode 100755 index 6b901f8b..d47e5cb2 --- a/backend/database/seeders/DatabaseSeeder.php +++ b/backend/database/seeders/DatabaseSeeder.php @@ -18,8 +18,13 @@ class DatabaseSeeder extends Seeder // User::factory(10)->create(); User::factory()->create([ - 'name' => 'Test User', + 'username' => 'test', 'email' => 'test@example.com', + 'password' => 'password123@', + ]); + $this->call([ + ProvinceSeeder::class, + CitySeeder::class, ]); } } diff --git a/backend/database/seeders/DocumentSeeder.php b/backend/database/seeders/DocumentSeeder.php new file mode 100755 index 00000000..da446869 --- /dev/null +++ b/backend/database/seeders/DocumentSeeder.php @@ -0,0 +1,17 @@ +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(),], + ]); + } +} diff --git a/backend/database/seeders/PaymentSeeder.php b/backend/database/seeders/PaymentSeeder.php new file mode 100644 index 00000000..dd108b7b --- /dev/null +++ b/backend/database/seeders/PaymentSeeder.php @@ -0,0 +1,17 @@ +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(),], + ]); + } +} diff --git a/backend/database/seeders/ProvinceSeeder.php b/backend/database/seeders/ProvinceSeeder.php new file mode 100755 index 00000000..325597d8 --- /dev/null +++ b/backend/database/seeders/ProvinceSeeder.php @@ -0,0 +1,37 @@ +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()], + ]); + } +} diff --git a/backend/database/seeders/TransactionSeeder.php b/backend/database/seeders/TransactionSeeder.php new file mode 100644 index 00000000..07edc4fb --- /dev/null +++ b/backend/database/seeders/TransactionSeeder.php @@ -0,0 +1,17 @@ + 'رسالة استثناء: :message', + 'exception_trace' => 'تتبع الإستثناء: :trace', + 'exception_message_title' => 'رسالة استثناء', + 'exception_trace_title' => 'تتبع الإستثناء', + + 'backup_failed_subject' => 'أخفق النسخ الاحتياطي لل :application_name', + 'backup_failed_body' => 'مهم: حدث خطأ أثناء النسخ الاحتياطي :application_name', + + 'backup_successful_subject' => 'نسخ احتياطي جديد ناجح ل :application_name', + 'backup_successful_subject_title' => 'نجاح النسخ الاحتياطي الجديد!', + 'backup_successful_body' => 'أخبار عظيمة، نسخة احتياطية جديدة ل :application_name تم إنشاؤها بنجاح على القرص المسمى :disk_name.', + + 'cleanup_failed_subject' => 'فشل تنظيف النسخ الاحتياطي للتطبيق :application_name .', + 'cleanup_failed_body' => 'حدث خطأ أثناء تنظيف النسخ الاحتياطية ل :application_name', + + 'cleanup_successful_subject' => 'تنظيف النسخ الاحتياطية ل :application_name تمت بنجاح', + 'cleanup_successful_subject_title' => 'تنظيف النسخ الاحتياطية تم بنجاح!', + 'cleanup_successful_body' => 'تنظيف النسخ الاحتياطية ل :application_name على القرص المسمى :disk_name تم بنجاح.', + + 'healthy_backup_found_subject' => 'النسخ الاحتياطية ل :application_name على القرص :disk_name صحية', + 'healthy_backup_found_subject_title' => 'النسخ الاحتياطية ل :application_name صحية', + 'healthy_backup_found_body' => 'تعتبر النسخ الاحتياطية ل :application_name صحية. عمل جيد!', + + 'unhealthy_backup_found_subject' => 'مهم: النسخ الاحتياطية ل :application_name غير صحية', + 'unhealthy_backup_found_subject_title' => 'مهم: النسخ الاحتياطية ل :application_name غير صحية. :problem', + 'unhealthy_backup_found_body' => 'النسخ الاحتياطية ل :application_name على القرص :disk_name غير صحية.', + 'unhealthy_backup_found_not_reachable' => 'لا يمكن الوصول إلى وجهة النسخ الاحتياطي. :error', + 'unhealthy_backup_found_empty' => 'لا توجد نسخ احتياطية لهذا التطبيق على الإطلاق.', + 'unhealthy_backup_found_old' => 'تم إنشاء أحدث النسخ الاحتياطية في :date وتعتبر قديمة جدا.', + 'unhealthy_backup_found_unknown' => 'عذرا، لا يمكن تحديد سبب دقيق.', + 'unhealthy_backup_found_full' => 'النسخ الاحتياطية تستخدم الكثير من التخزين. الاستخدام الحالي هو :disk_usage وهو أعلى من الحد المسموح به من :disk_limit.', + + 'no_backups_info' => 'لم يتم عمل نسخ احتياطية حتى الآن', + 'application_name' => 'اسم التطبيق', + 'backup_name' => 'اسم النسخ الاحتياطي', + 'disk' => 'القرص', + 'newest_backup_size' => 'أحدث حجم للنسخ الاحتياطي', + 'number_of_backups' => 'عدد النسخ الاحتياطية', + 'total_storage_used' => 'إجمالي مساحة التخزين المستخدمة', + 'newest_backup_date' => 'أحدث تاريخ النسخ الاحتياطي', + 'oldest_backup_date' => 'أقدم تاريخ نسخ احتياطي', +]; diff --git a/backend/resources/lang/en/auth.php b/backend/resources/lang/en/auth.php new file mode 100755 index 00000000..6598e2c0 --- /dev/null +++ b/backend/resources/lang/en/auth.php @@ -0,0 +1,20 @@ + 'These credentials do not match our records.', + 'password' => 'The provided password is incorrect.', + 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', + +]; diff --git a/backend/resources/lang/en/messages.php b/backend/resources/lang/en/messages.php new file mode 100755 index 00000000..b0f55d0f --- /dev/null +++ b/backend/resources/lang/en/messages.php @@ -0,0 +1,11 @@ + 'The operation was successful.', + 'invalid_credential' => 'Provided credential is invalid.', + 'incorrect_current_password' => 'Current password is incorrect.', + 'new_password_email_sent' => 'Your new password sent to your email', + 'file_upload_failed' => 'The file can not be uploaded.', + 'otp' => 'your otp token is : ', + 'incorrect_otp' => 'Incorrect OTP code.', +]; diff --git a/backend/resources/lang/en/pagination.php b/backend/resources/lang/en/pagination.php new file mode 100755 index 00000000..d4814118 --- /dev/null +++ b/backend/resources/lang/en/pagination.php @@ -0,0 +1,19 @@ + '« Previous', + 'next' => 'Next »', + +]; diff --git a/backend/resources/lang/en/passwords.php b/backend/resources/lang/en/passwords.php new file mode 100755 index 00000000..f1223bd7 --- /dev/null +++ b/backend/resources/lang/en/passwords.php @@ -0,0 +1,22 @@ + 'Your password has been reset.', + 'sent' => 'We have emailed your password reset link.', + 'throttled' => 'Please wait before retrying.', + 'token' => 'This password reset token is invalid.', + 'user' => "We can't find a user with that email address.", + +]; diff --git a/backend/resources/lang/en/validation.php b/backend/resources/lang/en/validation.php new file mode 100755 index 00000000..f7bd0407 --- /dev/null +++ b/backend/resources/lang/en/validation.php @@ -0,0 +1,186 @@ + 'The :attribute field must be accepted.', + 'accepted_if' => 'The :attribute field must be accepted when :other is :value.', + 'active_url' => 'The :attribute field must be a valid URL.', + 'after' => 'The :attribute field must be a date after :date.', + 'after_or_equal' => 'The :attribute field must be a date after or equal to :date.', + 'alpha' => 'The :attribute field must only contain letters.', + 'alpha_dash' => 'The :attribute field must only contain letters, numbers, dashes, and underscores.', + 'alpha_num' => 'The :attribute field must only contain letters and numbers.', + 'array' => 'The :attribute field must be an array.', + 'ascii' => 'The :attribute field must only contain single-byte alphanumeric characters and symbols.', + 'before' => 'The :attribute field must be a date before :date.', + 'before_or_equal' => 'The :attribute field must be a date before or equal to :date.', + 'between' => [ + 'array' => 'The :attribute field must have between :min and :max items.', + 'file' => 'The :attribute field must be between :min and :max kilobytes.', + 'numeric' => 'The :attribute field must be between :min and :max.', + 'string' => 'The :attribute field must be between :min and :max characters.', + ], + 'boolean' => 'The :attribute field must be true or false.', + 'confirmed' => 'The :attribute field confirmation does not match.', + 'current_password' => 'The password is incorrect.', + 'date' => 'The :attribute field must be a valid date.', + 'date_equals' => 'The :attribute field must be a date equal to :date.', + 'date_format' => 'The :attribute field must match the format :format.', + 'decimal' => 'The :attribute field must have :decimal decimal places.', + 'declined' => 'The :attribute field must be declined.', + 'declined_if' => 'The :attribute field must be declined when :other is :value.', + 'different' => 'The :attribute field and :other must be different.', + 'digits' => 'The :attribute field must be :digits digits.', + 'digits_between' => 'The :attribute field must be between :min and :max digits.', + 'dimensions' => 'The :attribute field has invalid image dimensions.', + 'distinct' => 'The :attribute field has a duplicate value.', + 'doesnt_end_with' => 'The :attribute field must not end with one of the following: :values.', + 'doesnt_start_with' => 'The :attribute field must not start with one of the following: :values.', + 'email' => 'The :attribute field must be a valid email address.', + 'ends_with' => 'The :attribute field must end with one of the following: :values.', + 'enum' => 'The selected :attribute is invalid.', + 'exists' => 'The selected :attribute is invalid.', + 'file' => 'The :attribute field must be a file.', + 'filled' => 'The :attribute field must have a value.', + 'gt' => [ + 'array' => 'The :attribute field must have more than :value items.', + 'file' => 'The :attribute field must be greater than :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than :value.', + 'string' => 'The :attribute field must be greater than :value characters.', + ], + 'gte' => [ + 'array' => 'The :attribute field must have :value items or more.', + 'file' => 'The :attribute field must be greater than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be greater than or equal to :value.', + 'string' => 'The :attribute field must be greater than or equal to :value characters.', + ], + 'image' => 'The :attribute field must be an image.', + 'in' => 'The selected :attribute is invalid.', + 'in_array' => 'The :attribute field must exist in :other.', + 'integer' => 'The :attribute field must be an integer.', + 'ip' => 'The :attribute field must be a valid IP address.', + 'ipv4' => 'The :attribute field must be a valid IPv4 address.', + 'ipv6' => 'The :attribute field must be a valid IPv6 address.', + 'json' => 'The :attribute field must be a valid JSON string.', + 'lowercase' => 'The :attribute field must be lowercase.', + 'lt' => [ + 'array' => 'The :attribute field must have less than :value items.', + 'file' => 'The :attribute field must be less than :value kilobytes.', + 'numeric' => 'The :attribute field must be less than :value.', + 'string' => 'The :attribute field must be less than :value characters.', + ], + 'lte' => [ + 'array' => 'The :attribute field must not have more than :value items.', + 'file' => 'The :attribute field must be less than or equal to :value kilobytes.', + 'numeric' => 'The :attribute field must be less than or equal to :value.', + 'string' => 'The :attribute field must be less than or equal to :value characters.', + ], + 'mac_address' => 'The :attribute field must be a valid MAC address.', + 'max' => [ + 'array' => 'The :attribute field must not have more than :max items.', + 'file' => 'The :attribute field must not be greater than :max kilobytes.', + 'numeric' => 'The :attribute field must not be greater than :max.', + 'string' => 'The :attribute field must not be greater than :max characters.', + ], + 'max_digits' => 'The :attribute field must not have more than :max digits.', + 'mimes' => 'The :attribute field must be a file of type: :values.', + 'mimetypes' => 'The :attribute field must be a file of type: :values.', + 'min' => [ + 'array' => 'The :attribute field must have at least :min items.', + 'file' => 'The :attribute field must be at least :min kilobytes.', + 'numeric' => 'The :attribute field must be at least :min.', + 'string' => 'The :attribute field must be at least :min characters.', + ], + 'min_digits' => 'The :attribute field must have at least :min digits.', + 'missing' => 'The :attribute field must be missing.', + 'missing_if' => 'The :attribute field must be missing when :other is :value.', + 'missing_unless' => 'The :attribute field must be missing unless :other is :value.', + 'missing_with' => 'The :attribute field must be missing when :values is present.', + 'missing_with_all' => 'The :attribute field must be missing when :values are present.', + 'multiple_of' => 'The :attribute field must be a multiple of :value.', + 'not_in' => 'The selected :attribute is invalid.', + 'not_regex' => 'The :attribute field format is invalid.', + 'numeric' => 'The :attribute field must be a number.', + 'password' => [ + 'letters' => 'The :attribute field must contain at least one letter.', + 'mixed' => 'The :attribute field must contain at least one uppercase and one lowercase letter.', + 'numbers' => 'The :attribute field must contain at least one number.', + 'symbols' => 'The :attribute field must contain at least one symbol.', + 'uncompromised' => 'The given :attribute has appeared in a data leak. Please choose a different :attribute.', + ], + 'present' => 'The :attribute field must be present.', + 'prohibited' => 'The :attribute field is prohibited.', + 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', + 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', + 'prohibits' => 'The :attribute field prohibits :other from being present.', + 'regex' => 'The :attribute field format is invalid.', + 'required' => 'The :attribute field is required.', + 'required_array_keys' => 'The :attribute field must contain entries for: :values.', + 'required_if' => 'The :attribute field is required when :other is :value.', + 'required_if_accepted' => 'The :attribute field is required when :other is accepted.', + 'required_unless' => 'The :attribute field is required unless :other is in :values.', + 'required_with' => 'The :attribute field is required when :values is present.', + 'required_with_all' => 'The :attribute field is required when :values are present.', + 'required_without' => 'The :attribute field is required when :values is not present.', + 'required_without_all' => 'The :attribute field is required when none of :values are present.', + 'same' => 'The :attribute field must match :other.', + 'size' => [ + 'array' => 'The :attribute field must contain :size items.', + 'file' => 'The :attribute field must be :size kilobytes.', + 'numeric' => 'The :attribute field must be :size.', + 'string' => 'The :attribute field must be :size characters.', + ], + 'starts_with' => 'The :attribute field must start with one of the following: :values.', + 'string' => 'The :attribute field must be a string.', + 'timezone' => 'The :attribute field must be a valid timezone.', + 'unique' => 'The :attribute has already been taken.', + 'uploaded' => 'The :attribute failed to upload.', + 'uppercase' => 'The :attribute field must be uppercase.', + 'url' => 'The :attribute field must be a valid URL.', + 'ulid' => 'The :attribute field must be a valid ULID.', + 'uuid' => 'The :attribute field must be a valid UUID.', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [ + 'phone_number' => 'phone number', + ], + +]; diff --git a/backend/resources/lang/fa/auth.php b/backend/resources/lang/fa/auth.php new file mode 100755 index 00000000..88976891 --- /dev/null +++ b/backend/resources/lang/fa/auth.php @@ -0,0 +1,20 @@ + 'اطلاعات وارد شده صحیح نمی باشد', + 'password' => 'رمزعبور صحیح نیست', + 'throttle' => 'درخواست بیش از حد مجاز! لطفا بعد از :seconds ثانیه دوباره امتحان کنید', + +]; diff --git a/backend/resources/lang/fa/messages.php b/backend/resources/lang/fa/messages.php new file mode 100755 index 00000000..ec215a9a --- /dev/null +++ b/backend/resources/lang/fa/messages.php @@ -0,0 +1,11 @@ + 'عملیات با موفقیت انجام شد.', + 'invalid_credential' => 'نام کاربری یا رمز عبور اشتباه است', + 'incorrect_current_password' => 'رمز عبور فعلی اشتباه است', + 'new_password_email_sent' => 'رمز عبور جدید به ایمیل شما ارسال شد.', + 'file_upload_failed' => 'بارگذاری فایل با خطا مواجه شد.', + 'otp' => 'کد ورود شما : ', + 'incorrect_otp' => 'کد تایید اشتباه است .', +]; diff --git a/backend/resources/lang/fa/pagination.php b/backend/resources/lang/fa/pagination.php new file mode 100755 index 00000000..e00adbf9 --- /dev/null +++ b/backend/resources/lang/fa/pagination.php @@ -0,0 +1,19 @@ + '« قبلی', + 'next' => 'بعدی »', + +]; diff --git a/backend/resources/lang/fa/passwords.php b/backend/resources/lang/fa/passwords.php new file mode 100755 index 00000000..c8081d97 --- /dev/null +++ b/backend/resources/lang/fa/passwords.php @@ -0,0 +1,22 @@ + 'رمز عبور شما با موفقیت بازیابی شد', + 'sent' => 'ایمیلی جهت بازیابی رمزعبور برای شما ارسال شد', + 'throttled' => 'لطفا اندکی صبر کنید و دوباره امتحان کنید', + 'token' => 'مشخصه بازیابی رمزعبور شما صحیح نمی باشد', + 'user' => "کاربری با این اطلاعات وجود ندارد", + +]; diff --git a/backend/resources/lang/fa/validation.php b/backend/resources/lang/fa/validation.php new file mode 100755 index 00000000..53fd3e1b --- /dev/null +++ b/backend/resources/lang/fa/validation.php @@ -0,0 +1,192 @@ + 'گزینه :attribute باید تایید شود', + 'accepted_if' => 'زمانی که گزینه :other برابر :value است :attribute باید تایید شود', + 'active_url' => 'گزینه :attribute یک آدرس سایت معتبر نیست', + 'after' => 'گزینه :attribute باید تاریخی بعد از :date باشد', + 'after_or_equal' => 'گزینه :attribute باید تاریخی مساوی یا بعد از :date باشد', + 'alpha' => 'گزینه :attribute باید تنها شامل حروف باشد', + 'alpha_dash' => 'گزینه :attribute باید تنها شامل حروف، اعداد، خط تیره و زیر خط باشد', + 'alpha_num' => 'گزینه :attribute باید تنها شامل حروف و اعداد باشد', + 'array' => 'گزینه :attribute باید آرایه باشد', + 'ascii' => 'گزینه :attribute تنها میتواند شامل تک حرف، عدد یا نماد ها باشد. .', + 'before' => 'گزینه :attribute باید تاریخی قبل از :date باشد', + 'before_or_equal' => 'گزینه :attribute باید تاریخی مساوی یا قبل از :date باشد', + 'between' => [ + 'array' => 'گزینه :attribute باید بین :min و :max آیتم باشد', + 'file' => 'گزینه :attribute باید بین :min و :max کیلوبایت باشد', + 'numeric' => 'گزینه :attribute باید بین :min و :max باشد', + 'string' => 'گزینه :attribute باید بین :min و :max کاراکتر باشد', + ], + 'boolean' => 'گزینه :attribute تنها می تواند صحیح یا غلط باشد', + 'confirmed' => 'تایید مجدد گزینه :attribute صحیح نمی باشد', + 'current_password' => 'رمزعبور صحیح نمی باشد', + 'date' => 'گزینه :attribute یک تاریخ صحیح نمی باشد', + 'date_equals' => 'گزینه :attribute باید تاریخی مساوی با :date باشد', + 'date_format' => 'گزینه :attribute با فرمت :format همخوانی ندارد', + 'decimal' => 'گزینه :attribute باید :decimal رقم اعشار داشته باشد.', + 'declined' => 'گزینه :attribute باید رد شود', + 'declined_if' => 'گزینه :attribute زمانی که :other برابر :value است باید رد شود', + 'different' => 'گزینه :attribute و :other باید متفاوت باشند', + 'digits' => 'گزینه :attribute باید :digits عدد باشد', + 'digits_between' => 'گزینه :attribute باید بین :min و :max عدد باشد', + 'dimensions' => 'ابعاد تصویر گزینه :attribute مجاز نمی باشد', + 'distinct' => 'گزینه :attribute دارای افزونگی داده می باشد', + 'doesnt_end_with' => 'گزینه :attribute نباید با این مقادیر به پایان برسد: :values.', + 'doesnt_start_with' => 'گزینه :attribute نباید با این مقادیر شروع شود: :values.', + 'email' => 'گزینه :attribute باید یک آدرس ایمیل صحیح باشد', + 'ends_with' => 'گزینه :attribute باید با یکی از این مقادیر پایان یابد، :values', + 'enum' => 'گزینه :attribute صحیح نمی باشد', + 'exists' => 'گزینه انتخاب شده :attribute صحیح نمی باشد', + 'file' => 'گزینه :attribute باید یک فایل باشد', + 'filled' => 'گزینه :attribute نمی تواند خالی باشد', + 'gt' => [ + 'array' => 'گزینه :attribute باید بیشتر از :value آیتم باشد', + 'file' => 'گزینه :attribute باید بزرگتر از :value کیلوبایت باشد', + 'numeric' => 'گزینه :attribute باید بزرگتر از :value باشد', + 'string' => 'گزینه :attribute باید بزرگتر از :value کاراکتر باشد', + ], + 'gte' => [ + 'array' => 'گزینه :attribute باید :value آیتم یا بیشتر داشته باشد', + 'file' => 'گزینه :attribute باید بزرگتر یا مساوی :value کیلوبایت باشد', + 'numeric' => 'گزینه :attribute باید بزرگتر یا مساوی :value باشد', + 'string' => 'گزینه :attribute باید بزرگتر یا مساوی :value کاراکتر باشد', + ], + 'image' => 'گزینه :attribute باید از نوع تصویر باشد', + 'in' => 'گزینه انتخابی :attribute صحیح نمی باشد', + 'in_array' => 'گزینه :attribute در :other وجود ندارد', + 'integer' => 'گزینه :attribute باید از نوع عددی باشد', + 'ip' => 'گزینه :attribute باید آی پی آدرس باشد', + 'ipv4' => 'گزینه :attribute باید آی پی آدرس ورژن 4 باشد', + 'ipv6' => 'گزینه :attribute باید آی پی آدرس ورژن 6 باشد', + 'json' => 'گزینه :attribute باید از نوع رشته جیسون باشد', + 'lowercase' => 'گزینه :attribute باید با حروف کوچک باشد.', + 'lt' => [ + 'array' => 'گزینه :attribute باید کمتر از :value آیتم داشته باشد', + 'file' => 'گزینه :attribute باید کمتر از :value کیلوبایت باشد', + 'numeric' => 'گزینه :attribute باید کمتر از :value باشد', + 'string' => 'گزینه :attribute باید کمتر از :value کاراکتر باشد', + ], + 'lte' => [ + 'array' => 'گزینه :attribute نباید کمتر از :value آیتم داشته باشد', + 'file' => 'گزینه :attribute باید مساوی یا کمتر از :value کیلوبایت باشد', + 'numeric' => 'گزینه :attribute باید مساوی یا کمتر از :value باشد', + 'string' => 'گزینه :attribute باید مساوی یا کمتر از :value کاراکتر باشد', + ], + 'mac_address' => 'گزینه :attribute باید یک مک آدرس معتبر باشد', + 'max' => [ + 'array' => 'گزینه :attribute نباید بیشتر از :max آیتم داشته باشد', + 'file' => 'گزینه :attribute نباید بزرگتر از :max کیلوبایت باشد', + 'numeric' => 'گزینه :attribute نباید بزرگتر از :max باشد', + 'string' => 'گزینه :attribute نباید بزرگتر از :max کاراکتر باشد', + ], + 'max_digits' => 'گزینه :attribute نباید بیشتر از :max رقم باشد', + 'mimes' => 'گزینه :attribute باید دارای یکی از این فرمت ها باشد: :values', + 'mimetypes' => 'گزینه :attribute باید دارای یکی از این فرمت ها باشد: :values', + 'min' => [ + 'array' => 'گزینه :attribute باید حداقل :min آیتم داشته باشد', + 'file' => 'گزینه :attribute باید حداقل :min کیلوبایت باشد', + 'numeric' => 'گزینه :attribute باید حداقل :min باشد', + 'string' => 'گزینه :attribute باید حداقل :min کاراکتر باشد', + ], + 'min_digits' => 'گزینه :attribute باید حداقل :min رقم باشد', + 'missing' => 'گزینه :attribute نباید تعریف شود.', + 'missing_if' => 'گزینه :attribute زمانی که مقدار :other برابر :value می باشد، نباید تعریف شود', + 'missing_unless' => 'گزینه :attribute نباید تعریف شود مگر اینکه گزینه :other برابر :value باشد', + 'missing_with' => 'گزینه :attribute زمانی که مقدار :values تعریف شده است دیگر نباید تعریف شود.', + 'missing_with_all' => 'گزینه :attribute زمانی که :values مقدار دارد دیگر نباید تعریف شود.', + 'multiple_of' => 'گزینه :attribute باید حاصل ضرب :value باشد', + 'not_in' => 'گزینه انتخابی :attribute صحیح نمی باشد', + 'not_regex' => 'فرمت گزینه :attribute صحیح نمی باشد', + 'numeric' => 'گزینه :attribute باید از نوع عددی باشد', + 'password' => [ + 'letters' => 'گزینه :attribute باید حداقل شامل یک حرف باشد', + 'mixed' => 'گزینه :attribute باید شامل حداقل یک حرف بزرگ و یک حرف کوچک باشد', + 'numbers' => 'گزینه :attribute باید شامل حداقل یک عدد باشد', + 'symbols' => 'گزینه :attribute باید شامل حداقل یک کارکتر خاص باشد', + 'uncompromised' => 'محتوای وارده شده در :attribute ایمن نمی باشد. لطفا گزینه :attribute را اصلاح فرمایید', + ], + 'present' => 'گزینه :attribute باید از نوع درصد باشد', + 'prohibited' => 'گزینه :attribute مجاز نمی باشد', + 'prohibited_if' => 'گزینه :attribute زمانی که :other برابر :value باشد مجاز نمی باشد', + 'prohibited_unless' => 'گزینه :attribute مجاز نیست مگر :other برابر :values باشد', + 'prohibits' => 'گزینه :attribute باعث ممنوعیت :other می باشد', + 'regex' => 'فرمت گزینه :attribute صحیح نمی باشد', + 'required' => 'تکمیل گزینه :attribute الزامی است', + 'required_array_keys' => 'گزینه :attribute باید شامل مقادیر: :values باشد', + 'required_if' => 'تکمیل گزینه :attribute زمانی که :other دارای مقدار :value است الزامی می باشد', + 'required_if_accepted' => 'تکمیل گزینه :attribute زمانی که :other انتخاب شده الزامی است', + 'required_unless' => 'تکمیل گزینه :attribute الزامی می باشد مگر :other دارای مقدار :values باشد', + 'required_with' => 'تکمیل گزینه :attribute زمانی که مقدار :values درصد است الزامی است', + 'required_with_all' => 'تکمیل گزینه :attribute زمانی که مقادیر :values درصد است الزامی می باشد', + 'required_without' => 'تکمیل گزینه :attribute زمانی که مقدار :values درصد نیست الزامی است', + 'required_without_all' => 'تکمیل گزینه :attribute زمانی که هیچ کدام از مقادیر :values درصد نیست الزامی است', + 'same' => 'گزینه های :attribute و :other باید یکی باشند', + 'size' => [ + 'array' => 'گزینه :attribute باید شامل :size آیتم باشد', + 'file' => 'گزینه :attribute باید :size کیلوبایت باشد', + 'numeric' => 'گزینه :attribute باید :size باشد', + 'string' => 'گزینه :attribute باید :size کاراکتر باشد', + ], + 'starts_with' => 'گزینه :attribute باید با یکی از این مقادیر شروع شود، :values', + 'string' => 'گزینه :attribute باید تنها شامل حروف باشد', + 'timezone' => 'گزینه :attribute باید از نوع منطقه زمانی صحیح باشد', + 'unique' => 'این :attribute از قبل ثبت شده است', + 'uploaded' => 'بارگذاری گزینه :attribute شکست خورد', + 'uppercase' => 'گزینه :attribute باید با حروف بزرگ باشد', + 'url' => 'فرمت :attribute اشتباه است', + 'ulid' => 'گزینه :attribute باید یک ULID صحیح باشد.', + 'uuid' => 'گزینه :attribute باید یک UUID صحیح باشد', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [ + 'name' => 'نام', + 'username' => 'نام کاربری', + 'email' => 'ایمیل', + 'first_name' => 'نام', + 'last_name' => 'نام خانوادگی', + 'password' => 'رمز عبور', + 'password_confirmation' => 'تاییدیه رمز عبور', + ], + +]; diff --git a/backend/resources/views/emails/login-notification.blade.php b/backend/resources/views/emails/login-notification.blade.php new file mode 100755 index 00000000..035c3c5c --- /dev/null +++ b/backend/resources/views/emails/login-notification.blade.php @@ -0,0 +1,24 @@ + + + + + Login Notification + + +

Hello {{ $user->username }}

+ +

You have successfully logged in to your account.

+ +

+ Email: {{ $user->email }} +

+ +

+ If this login was not done by you, please contact support immediately. +

+ +
+ +

Thank you.

+ + diff --git a/backend/resources/views/welcome.blade.php b/backend/resources/views/welcome.blade.php old mode 100644 new mode 100755 diff --git a/backend/routes/api.php b/backend/routes/api.php new file mode 100755 index 00000000..5eaa6efa --- /dev/null +++ b/backend/routes/api.php @@ -0,0 +1,19 @@ +user(); +})->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'); + }); + +}); diff --git a/backend/routes/console.php b/backend/routes/console.php old mode 100644 new mode 100755 diff --git a/backend/routes/expert.php b/backend/routes/expert.php new file mode 100755 index 00000000..40a27bdd --- /dev/null +++ b/backend/routes/expert.php @@ -0,0 +1,86 @@ +name('auth.') + ->controller(AuthController::class) + ->group(function () { + Route::post('login', 'login')->name('login'); + Route::post('logout', 'logout')->name('logout'); +}); + +Route::prefix('documents') + ->name('documents.') + ->middleware('auth:expert') + ->controller(DocumentationController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('confirm/{user}', 'confirm')->name('confirm'); + Route::post('reject/{user}', 'reject')->name('reject'); + Route::get('files/{user}', 'files')->name('files'); + }); + +Route::prefix('user_management') + ->middleware(['auth:expert', 'permission:user-management']) + ->name('user_management.') + ->controller(UserManagementController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/', 'store')->name('store'); + Route::get('/{user}', 'show')->name('show'); + Route::post('/{user}', 'update')->name('update'); + Route::delete('/{user}', 'destroy')->name('destroy'); + }); + +Route::prefix('roles') + ->name('roles.') + ->middleware(['auth:expert', 'permission:role-management']) + ->controller(RoleManagementController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/', 'store')->name('store'); + Route::get('/{role}', 'show')->name('show'); + Route::post('/{role}', 'update')->name('update'); + Route::delete('/{role}', 'destroy')->name('destroy'); + }); + +Route::prefix('permissions') + ->name('permissions.') + ->middleware(['auth:expert', 'permission:permission-management']) + ->controller(PermissionManagementController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/', 'store')->name('store'); + Route::get('/{permission}', 'show')->name('show'); + Route::post('/{permission}', 'update')->name('update'); + Route::delete('/{permission}', 'destroy')->name('destroy'); + }); + +Route::prefix('expert') + ->name('expert.') + ->middleware(['auth:expert', 'permission:expert-management']) + ->controller(ExpertManagementController::class) + ->group(function () { + Route::get('/', 'index')->name('index'); + Route::post('/', 'store')->name('store'); + Route::get('/{expert}', 'show')->name('show'); + Route::post('/{expert}', 'update')->name('update'); + Route::delete('/{expert}', 'destroy')->name('destroy'); + }); + +Route::prefix('profile') + ->name('profile.') + ->middleware('auth') + ->controller(ProfileController::class) + ->group(function () { + Route::get('info', 'info')->name('info'); + Route::post('edit', 'edit')->name('edit'); + Route::post('change_password', 'changePassword')->name('changePassword'); + }); diff --git a/backend/routes/web.php b/backend/routes/web.php old mode 100644 new mode 100755 index 86a06c53..64cea66a --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -1,7 +1,57 @@ name('Auth.') + ->controller(AuthController::class) + ->group(function () { + Route::post('register', 'register')->name('register'); + Route::post('login', 'login')->name('login'); + Route::post('logout', 'logout')->name('logout'); + }); + +Route::prefix('profile') + ->name('profile.') + ->middleware('auth') + ->controller(ProfileController::class) + ->group(function () { + Route::get('info', 'info')->name('info'); + Route::post('edit', 'edit')->name('edit'); + 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'); + }); diff --git a/backend/storage/app/.gitignore b/backend/storage/app/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/app/private/.gitignore b/backend/storage/app/private/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/app/public/.gitignore b/backend/storage/app/public/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/.gitignore b/backend/storage/framework/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/cache/.gitignore b/backend/storage/framework/cache/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/cache/data/.gitignore b/backend/storage/framework/cache/data/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/sessions/.gitignore b/backend/storage/framework/sessions/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/testing/.gitignore b/backend/storage/framework/testing/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/framework/views/.gitignore b/backend/storage/framework/views/.gitignore old mode 100644 new mode 100755 diff --git a/backend/storage/logs/.gitignore b/backend/storage/logs/.gitignore old mode 100644 new mode 100755 diff --git a/backend/tests/Feature/ExampleTest.php b/backend/tests/Feature/ExampleTest.php old mode 100644 new mode 100755 diff --git a/backend/tests/Pest.php b/backend/tests/Pest.php old mode 100644 new mode 100755 diff --git a/backend/tests/TestCase.php b/backend/tests/TestCase.php old mode 100644 new mode 100755 diff --git a/backend/tests/Unit/ExampleTest.php b/backend/tests/Unit/ExampleTest.php old mode 100644 new mode 100755 diff --git a/backend/vite.config.js b/backend/vite.config.js old mode 100644 new mode 100755 diff --git a/docker-compose.production.yml b/docker-compose.production.yml deleted file mode 100644 index 1d4536a6..00000000 --- a/docker-compose.production.yml +++ /dev/null @@ -1,60 +0,0 @@ -services: - postgres: - image: docker.arvancloud.ir/postgres:17.8-alpine3.23 - container_name: pgsql - restart: unless-stopped - ports: - - "8091:5432" - environment: - POSTGRES_DB: ${POSTGRES_DB} - POSTGRES_USER: ${POSTGRES_USER} - POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} - volumes: - - payment-db:/var/lib/postgresql/data - networks: - - payment - healthcheck: - test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] - interval: 30s - timeout: 10s - retries: 3 - - backend: - build: - context: ${BACKEND_PATH} - dockerfile: Dockerfile.production - container_name: laravel - tty: true - restart: unless-stopped - healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:80"] - interval: 30s - timeout: 10s - retries: 3 - ports: - - "8003:80" - - "443:443" - - "443:443/udp" - volumes: - - ${BACKEND_PATH}:/var/www/${PROJECT_NAME} - depends_on: - - postgres - networks: - - payment - logging: - driver: "syslog" - options: - syslog-address: "tcp://host.docker.internal:514" - tag: "laravel-backend" - syslog-facility: "daemon" - max-size: "10m" - mem_limit: 512M - cpus: 1 - -volumes: - payment-db: - driver: local - -networks: - payment: - driver: bridge \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 2da7a427..a93a5001 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,38 +1,68 @@ services: - postgres: - image: docker.arvancloud.ir/postgres:17.8-alpine3.23 - container_name: pgsql + nginx: + image: nginx:stable-alpine3.23-perl + container_name: nginx restart: unless-stopped ports: - - "8091:5432" + - "8000:80" + volumes: + - ./nginx/payment.conf:/etc/nginx/conf.d/default.conf + - ${BACKEND_PATH}:/var/www/${PROJECT_NAME} + networks: + - payment + + redis: + image: redis:8.6.0-alpine3.23 + container_name: redis + restart: unless-stopped + tty: true + networks: + - payment + + postgres: + image: postgres:18.2-alpine3.23 + container_name: payment-db + restart: unless-stopped + ports: + - "8092:5432" environment: POSTGRES_DB: ${POSTGRES_DB} POSTGRES_USER: ${POSTGRES_USER} POSTGRES_PASSWORD: ${POSTGRES_PASSWORD} + healthcheck: + test: [ "CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}" ] + interval: 30s + timeout: 10s + retries: 3 volumes: - payment-db:/var/lib/postgresql/data networks: - payment backend: - build: - context: ${BACKEND_PATH} - dockerfile: Dockerfile + image: payment-backend:latest container_name: laravel tty: true restart: unless-stopped ports: - - "8003:80" - - "443:443" - - "443:443/udp" + - "9000:9000" volumes: - ${BACKEND_PATH}:/var/www/${PROJECT_NAME} -# - caddy_data:/data -# - caddy_config:/config depends_on: - postgres networks: - payment + command: ["php", "artisan", "serve", "--host=0.0.0.0", "--port=9000"] + # Prints "Overridden command!" +# logging: +# driver: "syslog" +# options: +# syslog-address: "tcp://host.docker.internal:514" +# tag: "laravel-backend" +# syslog-facility: "daemon" +# max-size: "10m" +# mem_limit: 512M +# cpus: 1 volumes: payment-db: diff --git a/nginx/payment.conf b/nginx/payment.conf new file mode 100644 index 00000000..beee1ff4 --- /dev/null +++ b/nginx/payment.conf @@ -0,0 +1,21 @@ +server { + listen 80; + listen [::]:80; + charset utf-8; + + location / { + try_files $uri $uri/ /index.php?$query_string; + } + + location ~ ^/index\.php(/|$) { + include fastcgi_params; + fastcgi_pass laravel:9000; + fastcgi_index index.php; + fastcgi_hide_header X-Powered-By; + fastcgi_param SCRIPT_FILENAME /var/www/payment/public/index.php; + } + + location ~ /\.(?!well-known).* { + deny all; + } +}