Compare commits
10 Commits
feature/Ed
...
feature/Tr
| Author | SHA1 | Date | |
|---|---|---|---|
| 463ca3f006 | |||
| 1ba141e715 | |||
| 76e6ab4e0c | |||
| fb35ed58b1 | |||
| ffb4179e0d | |||
| a7fa1097b7 | |||
| f2f9d38907 | |||
| 5b79cefe28 | |||
| 41b7ead69e | |||
| 5ea986db40 |
@@ -4,7 +4,6 @@ namespace App\Admin\Controllers;
|
||||
|
||||
use App\Admin\Requests\ExpertManagement\StoreRequest;
|
||||
use App\Admin\Requests\ExpertManagement\UpdateRequest;
|
||||
use App\Admin\Resources\ExpertManagementResource;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\City;
|
||||
|
||||
@@ -24,7 +24,6 @@ class EditRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$user = $this->user();
|
||||
return [
|
||||
'username' => 'string|max:255',
|
||||
'first_name' => 'required|string',
|
||||
|
||||
66
backend/app/Enums/BusinessTypeEnum.php
Normal file
66
backend/app/Enums/BusinessTypeEnum.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum BusinessTypeEnum: int
|
||||
{
|
||||
case MEDICAL = 1;
|
||||
case LEGAL = 2;
|
||||
case ENGINEERING = 3;
|
||||
case EDUCATION = 4;
|
||||
case CONSULTING = 5;
|
||||
case BEAUTY = 6;
|
||||
case TECHNICAL_SERVICES = 7;
|
||||
case FINANCIAL = 8;
|
||||
case REAL_ESTATE = 9;
|
||||
case RESTAURANT = 10;
|
||||
case SHOP = 11;
|
||||
case TRANSPORTATION = 12;
|
||||
case ART = 13;
|
||||
case SPORT = 14;
|
||||
case OTHER = 15;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::MEDICAL => 'medical',
|
||||
self::LEGAL => 'legal',
|
||||
self::ENGINEERING => 'engineering',
|
||||
self::EDUCATION => 'education',
|
||||
self::CONSULTING => 'consulting',
|
||||
self::BEAUTY => 'beauty',
|
||||
self::TECHNICAL_SERVICES => 'technical_services',
|
||||
self::FINANCIAL => 'financial',
|
||||
self::REAL_ESTATE => 'real_estate',
|
||||
self::RESTAURANT => 'restaurant',
|
||||
self::SHOP => 'shop',
|
||||
self::TRANSPORTATION => 'transportation',
|
||||
self::ART => 'art',
|
||||
self::SPORT => 'sport',
|
||||
self::OTHER => 'other',
|
||||
};
|
||||
}
|
||||
|
||||
public function name($id): string
|
||||
{
|
||||
$mapArray = [
|
||||
1 => 'medical',
|
||||
2 => 'legal',
|
||||
3 => 'engineering',
|
||||
4 => 'education',
|
||||
5 => 'consulting',
|
||||
6 => 'beauty',
|
||||
7 => 'technical_services',
|
||||
8 => 'financial',
|
||||
9 => 'real_estate',
|
||||
10 => 'restaurant',
|
||||
11 => 'shop',
|
||||
12 => 'transportation',
|
||||
13 => 'art',
|
||||
14 => 'sport',
|
||||
15 => 'other',
|
||||
];
|
||||
|
||||
return $mapArray[$id];
|
||||
}
|
||||
}
|
||||
23
backend/app/Enums/PaymentStatusEnum.php
Normal file
23
backend/app/Enums/PaymentStatusEnum.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum PaymentStatusEnum:int
|
||||
{
|
||||
case Unpaid = 0;
|
||||
case Cancelled = 1;
|
||||
case Expired = 2;
|
||||
case Paid = 3;
|
||||
case Refunded = 4;
|
||||
|
||||
public function label(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Unpaid => 'unpaid',
|
||||
self::Cancelled => 'cancelled',
|
||||
self::Expired => 'expired',
|
||||
self::Paid => 'paid',
|
||||
self::Refunded => 'refunded',
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\GatewayCategoryFactory;
|
||||
use Database\Factories\BusinessTypeFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class GatewayCategory extends Model
|
||||
class BusinessType extends Model
|
||||
{
|
||||
/** @use HasFactory<GatewayCategoryFactory> */
|
||||
/** @use HasFactory<BusinessTypeFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
12
backend/app/Models/FibTransaction.php
Normal file
12
backend/app/Models/FibTransaction.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FibTransaction extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\FibTransactionFactory> */
|
||||
use HasFactory;
|
||||
}
|
||||
12
backend/app/Models/FibTransactionStatus.php
Normal file
12
backend/app/Models/FibTransactionStatus.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class FibTransactionStatus extends Model
|
||||
{
|
||||
/** @use HasFactory<\Database\Factories\FibTransactionStatusFactory> */
|
||||
use HasFactory;
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\GatewayFactory;
|
||||
use Database\Factories\TransactionFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Gateway extends Model
|
||||
class Transaction extends Model
|
||||
{
|
||||
/** @use HasFactory<GatewayFactory> */
|
||||
/** @use HasFactory<TransactionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
15
backend/app/Models/UserGateway.php
Normal file
15
backend/app/Models/UserGateway.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\UserGatewayFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class UserGateway extends Model
|
||||
{
|
||||
/** @use HasFactory<UserGatewayFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class AuthorizationService
|
||||
public function __construct()
|
||||
{
|
||||
$this->url = config('fib.authorization.url');
|
||||
$this->channelName = '';
|
||||
$this->channelName = 'fib_authorization';
|
||||
$this->inputParameters = [
|
||||
'client_id' => config('fib.authorization.client_id'),
|
||||
'client_secret' => config('fib.authorization.client_secret'),
|
||||
@@ -51,7 +51,6 @@ class AuthorizationService
|
||||
{
|
||||
return Http::asForm()
|
||||
->throw()
|
||||
->withoutVerifying()
|
||||
->post($this->url, $this->inputParameters)
|
||||
->json();
|
||||
}
|
||||
|
||||
97
backend/app/User/Controllers/GatewayManagementController.php
Normal file
97
backend/app/User/Controllers/GatewayManagementController.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Controllers;
|
||||
|
||||
use App\Enums\BusinessTypeEnum;
|
||||
use App\Facades\DataTable\DataTableFacade;
|
||||
use App\Facades\File\FileFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\UserGateway;
|
||||
use App\Traits\ApiResponse;
|
||||
use App\User\Requests\Gateway\StoreRequest;
|
||||
use App\User\Requests\Gateway\UpdateRequest;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Throwable;
|
||||
|
||||
class GatewayManagementController extends Controller
|
||||
{
|
||||
use ApiResponse;
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
return DataTableFacade::run(
|
||||
UserGateway::query()->where('user_id', '=', Auth::guard('web')->id()),
|
||||
$request,
|
||||
allowedFilters: ['*'],
|
||||
allowedSortings: ['*'],
|
||||
allowedSelects: ['id', 'name', 'domain', 'tax_id', 'bank_name', 'account_holder', 'iban', 'business_type_id', 'business_type_name'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function store(StoreRequest $request): JsonResponse
|
||||
{
|
||||
$user = Auth::guard('web')->user();
|
||||
|
||||
$logo = $request->has('logo') ? FileFacade::save($request->file('logo'), "{$user->id}") : null;
|
||||
|
||||
DB::transaction(function () use ($user, $logo, $request) {
|
||||
UserGateway::query()->create([
|
||||
'user_id' => $user->id,
|
||||
'username' => $user->username,
|
||||
'name' => $request->name,
|
||||
'domain' => $request->domain,
|
||||
'tax_id' => $request->tax_id,
|
||||
'bank_name' => $request->bank_name,
|
||||
'account_holder' => $request->account_holder,
|
||||
'iban' => $request->iban,
|
||||
'business_type_id' => $request->business_type_id,
|
||||
'business_type_name' => BusinessTypeEnum::name($request->business_type_id),
|
||||
'logo' => $logo,
|
||||
]);
|
||||
|
||||
$user->update(['authority_level' => 1]);
|
||||
});
|
||||
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function show(UserGateway $gateway): JsonResponse
|
||||
{
|
||||
return $this->successResponse($gateway);
|
||||
}
|
||||
|
||||
public function update(UpdateRequest $request, UserGateway $gateway): JsonResponse
|
||||
{
|
||||
$logo = null;
|
||||
$user = Auth::guard('web')->user();
|
||||
|
||||
if ($request->has('logo'))
|
||||
{
|
||||
FileFacade::delete($gateway->logo, true);
|
||||
$logo = FileFacade::save(request()->file('logo'), "{$user->id}");
|
||||
}
|
||||
|
||||
$gateway->update([
|
||||
'name' => $request->name,
|
||||
'domain' => $request->domain,
|
||||
'business_type_id' => $request->business_type_id,
|
||||
'business_type_name' => BusinessTypeEnum::name($request->business_type_id),
|
||||
'logo' => $logo,
|
||||
]);
|
||||
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
||||
public function destroy(UserGateway $gateway): JsonResponse
|
||||
{
|
||||
$gateway->delete();
|
||||
return $this->successResponse();
|
||||
}
|
||||
}
|
||||
@@ -2,14 +2,19 @@
|
||||
|
||||
namespace App\User\Controllers;
|
||||
|
||||
use App\Facades\File\FileFacade;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\City;
|
||||
use App\Models\Province;
|
||||
use App\Traits\ApiResponse;
|
||||
use App\User\Requests\Profile\ChangePasswordRequest;
|
||||
use App\User\Requests\Profile\EditRequest;
|
||||
use App\User\Resources\UserResource;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Throwable;
|
||||
|
||||
class ProfileController extends Controller
|
||||
{
|
||||
@@ -20,11 +25,40 @@ class ProfileController extends Controller
|
||||
return $this->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);
|
||||
|
||||
$user->update($request->validated());
|
||||
DB::transaction(function () use ($user, $province, $city, $request) {
|
||||
if ($user->kyc_status == 0)
|
||||
{
|
||||
$user->documents()->create([
|
||||
'title' => 'id_card',
|
||||
'url' => FileFacade::save($request->file('id_card'), "{$user->id}/"),
|
||||
]);
|
||||
}
|
||||
|
||||
$user->update([
|
||||
'first_name' => $request->first_name,
|
||||
'last_name' => $request->last_name,
|
||||
'national_id' => $request->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();
|
||||
}
|
||||
|
||||
37
backend/app/User/Requests/Gateway/StoreRequest.php
Normal file
37
backend/app/User/Requests/Gateway/StoreRequest.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Requests\Gateway;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class StoreRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::guard('web')->user()->kyc_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'domain' => 'required|string|max:255',
|
||||
'tax_id' => 'required|string',
|
||||
'bank_name' => 'required|string|max:255',
|
||||
'account_holder' => 'required|string',
|
||||
'iban' => 'required|string|max:255',
|
||||
'logo' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||
'business_type_id' => 'required|string|exists:business_types,id',
|
||||
];
|
||||
}
|
||||
}
|
||||
33
backend/app/User/Requests/Gateway/UpdateRequest.php
Normal file
33
backend/app/User/Requests/Gateway/UpdateRequest.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\User\Requests\Gateway;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return Auth::guard('web')->user()->kyc_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, ValidationRule|array|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'name' => 'required|string|max:255',
|
||||
'domain' => 'required|string|max:255',
|
||||
'business_type_id' => 'required|string|exists:business_types,id',
|
||||
'logo' => 'image|mimes:jpeg,png,jpg,gif,svg|max:2048',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\User\Requests\Profile;
|
||||
|
||||
use Illuminate\Contracts\Validation\ValidationRule;
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\Validator;
|
||||
|
||||
@@ -24,47 +25,20 @@ class EditRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$user = $this->user();
|
||||
$user = Auth::guard('web')->user();
|
||||
|
||||
return [
|
||||
'first_name' => [
|
||||
Rule::prohibitedIf($user->kyc_status == 1), 'string',
|
||||
],
|
||||
'last_name' => [
|
||||
Rule::prohibitedIf($user->kyc_status == 1), 'string',
|
||||
],
|
||||
'national_id' => [
|
||||
Rule::prohibitedIf($user->kyc_status == 1), 'string',
|
||||
],
|
||||
'address' => 'required',
|
||||
'postal_code' => 'required',
|
||||
'phone_number' => 'required',
|
||||
'province_id' => 'required',
|
||||
'city_id' => 'required',
|
||||
];
|
||||
}
|
||||
public function after(): array
|
||||
{
|
||||
return [
|
||||
function (Validator $validator) {
|
||||
$user = $this->user();
|
||||
if ($user->kyc_status == 1) {
|
||||
$lockedFields = [
|
||||
'first_name',
|
||||
'last_name',
|
||||
'national_id',
|
||||
];
|
||||
|
||||
foreach ($lockedFields as $field) {
|
||||
if ($this->filled($field)) {
|
||||
$validator->errors()->add(
|
||||
$field,
|
||||
'you cannot change this field.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
'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']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,18 @@ class UserResource extends JsonResource
|
||||
'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->provonce_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,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,6 +127,12 @@ return [
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
],
|
||||
|
||||
'fib_authorization' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/fib/authorization.log'),
|
||||
'level' => 'error',
|
||||
],
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\GatewayCategory;
|
||||
use App\Models\BusinessType;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<GatewayCategory>
|
||||
* @extends Factory<BusinessType>
|
||||
*/
|
||||
class GatewayCategoryFactory extends Factory
|
||||
class BusinessTypeFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
24
backend/database/factories/FibTransactionFactory.php
Normal file
24
backend/database/factories/FibTransactionFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\FibTransaction;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<FibTransaction>
|
||||
*/
|
||||
class FibTransactionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
24
backend/database/factories/FibTransactionStatusFactory.php
Normal file
24
backend/database/factories/FibTransactionStatusFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\FibTransactionStatus;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<FibTransactionStatus>
|
||||
*/
|
||||
class FibTransactionStatusFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Gateway;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Gateway>
|
||||
* @extends Factory<Transaction>
|
||||
*/
|
||||
class GatewayFactory extends Factory
|
||||
class TransactionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
24
backend/database/factories/UserGatewayFactory.php
Normal file
24
backend/database/factories/UserGatewayFactory.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\UserGateway;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<UserGateway>
|
||||
*/
|
||||
class UserGatewayFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ return new class extends Migration
|
||||
$table->string('national_id')->nullable();
|
||||
$table->string('address')->nullable();
|
||||
$table->string('postal_code')->nullable();
|
||||
$table->string('tax_id')->nullable();
|
||||
$table->string('phone_number')->nullable();
|
||||
$table->date('birth_date')->nullable();
|
||||
$table->foreignId('province_id')->nullable()->constrained('provinces');
|
||||
|
||||
@@ -11,7 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('gateway_categories', function (Blueprint $table) {
|
||||
Schema::create('business_types', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
@@ -23,6 +23,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('gateway_categories');
|
||||
Schema::dropIfExists('business_types');
|
||||
}
|
||||
};
|
||||
@@ -11,7 +11,7 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('gateways', function (Blueprint $table) {
|
||||
Schema::create('user_gateways', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users');
|
||||
$table->string('username');
|
||||
@@ -22,8 +22,8 @@ return new class extends Migration
|
||||
$table->string('account_holder');
|
||||
$table->string('logo')->nullable();
|
||||
$table->string('iban');
|
||||
$table->foreignId('category_id')->constrained('gateway_categories');
|
||||
$table->string('category_name');
|
||||
$table->foreignId('business_type_id')->constrained('business_types');
|
||||
$table->string('business_type_name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
@@ -33,6 +33,6 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('gateways');
|
||||
Schema::dropIfExists('user_gateways');
|
||||
}
|
||||
};
|
||||
@@ -23,7 +23,7 @@ return new class extends Migration
|
||||
$table->foreignId('status_id')->constrained('payment_statuses');
|
||||
$table->string('status_name');
|
||||
$table->ipAddress('ip');
|
||||
$table->foreignId('gateway_id')->constrained('gateways');
|
||||
$table->foreignId('user_gateway_id')->constrained('user_gateways');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('transactions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained('users');
|
||||
$table->string('amount');
|
||||
$table->string('currency');
|
||||
$table->string('callback_url');
|
||||
$table->string('description');
|
||||
$table->dateTime('expires_in');
|
||||
$table->foreignId('payment_id')->constrained('payments');
|
||||
$table->string('payment_track_id');
|
||||
$table->foreignId('user_gateway_id')->constrained('user_gateways');
|
||||
$table->integer('status');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('transactions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('fib_transaction_statuses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('fib_transaction_statuses');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('fib_transactions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('transaction_id')->constrained('transactions');
|
||||
$table->text('qrcode');
|
||||
$table->string('readable_code');
|
||||
$table->string('personalAppLink');
|
||||
$table->string('businessAppLink');
|
||||
$table->string('corporateAppLink');
|
||||
$table->string('paymentId');
|
||||
$table->string('paymentMethod');
|
||||
$table->timestamp('validUntil');
|
||||
$table->foreignId('status_id')->constrained('fib_transaction_statuses');
|
||||
$table->string('status_name');
|
||||
$table->timestamp('paidAt');
|
||||
$table->string('paidAmount');
|
||||
$table->string('paidCurrency');
|
||||
$table->string('decliningReason');
|
||||
$table->timestamp('declinedAt');
|
||||
$table->string('paidByName');
|
||||
$table->string('paidByIban');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('fib_transactions');
|
||||
}
|
||||
};
|
||||
34
backend/database/seeders/BusinessTypeSeeder.php
Normal file
34
backend/database/seeders/BusinessTypeSeeder.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class BusinessTypeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
DB::table('business_types')->insert([
|
||||
['id' => 1, 'name' => 'medical', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 2, 'name' => 'legal', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 3, 'name' => 'engineering', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 4, 'name' => 'education', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 5, 'name' => 'consulting', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 6, 'name' => 'beauty', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 7, 'name' => 'technical_services', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 8, 'name' => 'financial', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 9, 'name' => 'real_estate', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 10, 'name' => 'restaurant', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 11, 'name' => 'shop', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 12, 'name' => 'transportation', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 13, 'name' => 'art', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 14, 'name' => 'sport', 'created_at' => now(), 'updated_at' => now()],
|
||||
['id' => 15, 'name' => 'other', 'created_at' => now(), 'updated_at' => now()],
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ namespace Database\Seeders;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class GatewayCategorySeeder extends Seeder
|
||||
class FibTransactionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
17
backend/database/seeders/FibTransactionStatusSeeder.php
Normal file
17
backend/database/seeders/FibTransactionStatusSeeder.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class FibTransactionStatusSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class PaymentStatusSeeder extends Seeder
|
||||
{
|
||||
@@ -12,6 +13,12 @@ class PaymentStatusSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
DB::table('payment_statuses')->insert([
|
||||
['id' => 0, 'name' => 'unpaid', 'created_at' => now(), 'updated_at' => now(),],
|
||||
['id' => 1, 'name' => 'cancelled', 'created_at' => now(), 'updated_at' => now(),],
|
||||
['id' => 2, 'name' => 'expired', 'created_at' => now(), 'updated_at' => now(),],
|
||||
['id' => 3, 'name' => 'paid', 'created_at' => now(), 'updated_at' => now(),],
|
||||
['id' => 4, 'name' => 'refunded', 'created_at' => now(), 'updated_at' => now(),],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Database\Seeders;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class GatewaySeeder extends Seeder
|
||||
class TransactionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
17
backend/database/seeders/UserGatewaySeeder.php
Normal file
17
backend/database/seeders/UserGatewaySeeder.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserGatewaySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,7 @@ Route::prefix('user_management')
|
||||
Route::post('/{user}', 'update')->name('update');
|
||||
Route::delete('/{user}', 'destroy')->name('destroy');
|
||||
});
|
||||
|
||||
Route::prefix('roles')
|
||||
->name('roles.')
|
||||
->middleware(['auth:expert', 'permission:role-management'])
|
||||
@@ -50,6 +51,7 @@ Route::prefix('roles')
|
||||
Route::post('/{role}', 'update')->name('update');
|
||||
Route::delete('/{role}', 'destroy')->name('destroy');
|
||||
});
|
||||
|
||||
Route::prefix('permissions')
|
||||
->name('permissions.')
|
||||
->middleware(['auth:expert', 'permission:permission-management'])
|
||||
@@ -61,6 +63,7 @@ Route::prefix('permissions')
|
||||
Route::post('/{permission}', 'update')->name('update');
|
||||
Route::delete('/{permission}', 'destroy')->name('destroy');
|
||||
});
|
||||
|
||||
Route::prefix('expert')
|
||||
->name('expert.')
|
||||
->middleware(['auth:expert', 'permission:expert-management'])
|
||||
|
||||
@@ -5,6 +5,7 @@ use App\Admin\Controllers\PermissionManagementController;
|
||||
use App\Admin\Controllers\RoleManagementController;
|
||||
use App\Admin\Controllers\UserManagementController;
|
||||
use App\User\Controllers\AuthController;
|
||||
use App\User\Controllers\GatewayManagementController;
|
||||
use App\User\Controllers\ProfileController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
@@ -26,3 +27,15 @@ Route::prefix('profile')
|
||||
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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user