Compare commits
7 Commits
feature/Pa
...
feature/Ed
| Author | SHA1 | Date | |
|---|---|---|---|
| d04637b1ef | |||
| 3c61e279ec | |||
| e9f6ee71fa | |||
| 60129f5abb | |||
| 2d8f2dbcc5 | |||
| 86e353749a | |||
| f3a9b5e788 |
@@ -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();
|
||||
|
||||
39
backend/app/Admin/Requests/Profile/EditRequest.php
Executable file
39
backend/app/Admin/Requests/Profile/EditRequest.php
Executable 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',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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'];
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\BusinessTypeFactory;
|
||||
use Database\Factories\GatewayCategoryFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class BusinessType extends Model
|
||||
class GatewayCategory extends Model
|
||||
{
|
||||
/** @use HasFactory<BusinessTypeFactory> */
|
||||
/** @use HasFactory<GatewayCategoryFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Database\Factories\TransactionFactory;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Transaction extends Model
|
||||
{
|
||||
/** @use HasFactory<TransactionFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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.'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
<?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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\BusinessType;
|
||||
use App\Models\GatewayCategory;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<BusinessType>
|
||||
* @extends Factory<GatewayCategory>
|
||||
*/
|
||||
class BusinessTypeFactory extends Factory
|
||||
class GatewayCategoryFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
@@ -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.
|
||||
@@ -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 [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -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');
|
||||
}
|
||||
};
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class BusinessTypeSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -5,7 +5,7 @@ namespace Database\Seeders;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class UserGatewaySeeder extends Seeder
|
||||
class GatewaySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class TransactionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user