Compare commits

..

6 Commits

Author SHA1 Message Date
d04637b1ef fix code 2026-05-18 14:10:45 +03:30
3c61e279ec create profile for expert 2026-05-18 13:59:05 +03:30
e9f6ee71fa create profile for expert 2026-05-18 13:58:20 +03:30
60129f5abb create profile for expert 2026-05-18 13:57:03 +03:30
2d8f2dbcc5 create profile for expert 2026-05-18 13:50:37 +03:30
86e353749a create profile for expert 2026-05-18 13:49:33 +03:30
32 changed files with 129 additions and 449 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Admin\Controllers;
use App\Admin\Requests\Profile\ChangePasswordRequest;
use App\Admin\Requests\Profile\EditRequest;
use App\Admin\Resources\ExpertResource;
use App\Http\Controllers\Controller;
use App\Traits\ApiResponse;
@@ -19,6 +20,24 @@ class ProfileController extends Controller
return $this->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();

View File

@@ -0,0 +1,39 @@
<?php
namespace App\Admin\Requests\Profile;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
class EditRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, ValidationRule|array|string>
*/
public function rules(): array
{
$user = $this->user();
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',
];
}
}

View File

@@ -1,43 +0,0 @@
<?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',
};
}
}

View File

@@ -1,23 +0,0 @@
<?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',
};
}
}

View File

@@ -1,15 +0,0 @@
<?php
namespace App\Models;
use Database\Factories\BusinessTypeFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class BusinessType extends Model
{
/** @use HasFactory<BusinessTypeFactory> */
use HasFactory;
protected $guarded = ['id'];
}

View File

@@ -1,12 +0,0 @@
<?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;
}

View File

@@ -1,12 +0,0 @@
<?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;
}

View File

@@ -2,13 +2,13 @@
namespace App\Models;
use Database\Factories\UserGatewayFactory;
use Database\Factories\GatewayFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class UserGateway extends Model
class Gateway extends Model
{
/** @use HasFactory<UserGatewayFactory> */
/** @use HasFactory<GatewayFactory> */
use HasFactory;
protected $guarded = ['id'];

View File

@@ -2,13 +2,13 @@
namespace App\Models;
use Database\Factories\TransactionFactory;
use Database\Factories\GatewayCategoryFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Transaction extends Model
class GatewayCategory extends Model
{
/** @use HasFactory<TransactionFactory> */
/** @use HasFactory<GatewayCategoryFactory> */
use HasFactory;
protected $guarded = ['id'];

View File

@@ -1,18 +0,0 @@
<?php
namespace App\User\Controllers;
use App\Http\Controllers\Controller;
use App\Models\City;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
class CityController extends Controller
{
use ApiResponse;
public function list(): JsonResponse
{
return response()->json(City::all(['id', 'name']));
}
}

View File

@@ -24,17 +24,7 @@ class ProfileController extends Controller
{
$user = Auth::user();
$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' => $request->province_id,
'city_id' => $request->city_id,
'status' => 1
]);
$user->update($request->validated());
return $this->successResponse();
}

View File

@@ -1,17 +0,0 @@
<?php
namespace App\User\Controllers;
use App\Http\Controllers\Controller;
use App\Models\Province;
use App\Traits\ApiResponse;
use Illuminate\Http\JsonResponse;
class ProvinceController extends Controller
{
use ApiResponse;
public function list(): JsonResponse
{
return response()->json(Province::all(['id', 'name']));
}
}

View File

@@ -4,6 +4,8 @@ namespace App\User\Requests\Profile;
use Illuminate\Contracts\Validation\ValidationRule;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Validation\Validator;
class EditRequest extends FormRequest
{
@@ -22,10 +24,18 @@ class EditRequest extends FormRequest
*/
public function rules(): array
{
$user = $this->user();
return [
'first_name' => 'required|string',
'last_name' => 'required|string',
'national_id' => 'required',
'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',
@@ -33,4 +43,28 @@ class EditRequest extends FormRequest
'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.'
);
}
}
}
},
];
}
}

View File

@@ -1,24 +0,0 @@
<?php
namespace Database\Factories;
use App\Models\BusinessType;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<BusinessType>
*/
class BusinessTypeFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@@ -1,24 +0,0 @@
<?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 [
//
];
}
}

View File

@@ -2,13 +2,13 @@
namespace Database\Factories;
use App\Models\FibTransaction;
use App\Models\GatewayCategory;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<FibTransaction>
* @extends Factory<GatewayCategory>
*/
class FibTransactionFactory extends Factory
class GatewayCategoryFactory extends Factory
{
/**
* Define the model's default state.

View File

@@ -2,13 +2,13 @@
namespace Database\Factories;
use App\Models\UserGateway;
use App\Models\Gateway;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<UserGateway>
* @extends Factory<Gateway>
*/
class UserGatewayFactory extends Factory
class GatewayFactory extends Factory
{
/**
* Define the model's default state.

View File

@@ -1,24 +0,0 @@
<?php
namespace Database\Factories;
use App\Models\Transaction;
use Illuminate\Database\Eloquent\Factories\Factory;
/**
* @extends Factory<Transaction>
*/
class TransactionFactory extends Factory
{
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
return [
//
];
}
}

View File

@@ -11,7 +11,7 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('business_types', function (Blueprint $table) {
Schema::create('gateway_categories', 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('business_types');
Schema::dropIfExists('gateway_categories');
}
};

View File

@@ -11,7 +11,7 @@ return new class extends Migration
*/
public function up(): void
{
Schema::create('user_gateways', function (Blueprint $table) {
Schema::create('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('business_type_id')->constrained('business_types');
$table->string('business_type_name');
$table->foreignId('category_id')->constrained('gateway_categories');
$table->string('category_name');
$table->timestamps();
});
}
@@ -33,6 +33,6 @@ return new class extends Migration
*/
public function down(): void
{
Schema::dropIfExists('user_gateways');
Schema::dropIfExists('gateways');
}
};

View File

@@ -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('user_gateway_id')->constrained('user_gateways');
$table->foreignId('gateway_id')->constrained('gateways');
$table->timestamps();
});
}

View File

@@ -1,37 +0,0 @@
<?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('gateway_id')->constrained('gateways');
$table->integer('status');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('transactions');
}
};

View File

@@ -1,28 +0,0 @@
<?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');
}
};

View File

@@ -1,45 +0,0 @@
<?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');
}
};

View File

@@ -1,34 +0,0 @@
<?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()],
]);
}
}

View File

@@ -1,17 +0,0 @@
<?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
{
//
}
}

View File

@@ -5,7 +5,7 @@ namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class FibTransactionSeeder extends Seeder
class GatewayCategorySeeder extends Seeder
{
/**
* Run the database seeds.

View File

@@ -5,7 +5,7 @@ namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
class TransactionSeeder extends Seeder
class GatewaySeeder extends Seeder
{
/**
* Run the database seeds.

View File

@@ -4,7 +4,6 @@ namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class PaymentStatusSeeder extends Seeder
{
@@ -13,12 +12,6 @@ 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(),],
]);
//
}
}

View File

@@ -1,17 +0,0 @@
<?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
{
//
}
}

View File

@@ -4,6 +4,7 @@ use App\Admin\Controllers\AuthController;
use App\Admin\Controllers\DocumentationController;
use App\Admin\Controllers\ExpertManagementController;
use App\Admin\Controllers\PermissionManagementController;
use App\Admin\Controllers\ProfileController;
use App\Admin\Controllers\RoleManagementController;
use App\Admin\Controllers\UserManagementController;
@@ -71,3 +72,13 @@ Route::prefix('expert')
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');
});

View File

@@ -5,9 +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\CityController;
use App\User\Controllers\ProfileController;
use App\User\Controllers\ProvinceController;
use Illuminate\Support\Facades\Route;
Route::prefix('auth')
@@ -28,17 +26,3 @@ Route::prefix('profile')
Route::post('edit', 'edit')->name('edit');
Route::post('change_password', 'changePassword')->name('changePassword');
});
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');
});