From 575d74bc021f668530ccee5e6eb39a5d8be53746 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 18 Nov 2025 12:06:06 +0100 Subject: [PATCH] replace id_operator by id_operator_country --- app/Http/Controllers/WalletController.php | 12 ++++++------ ..._11_13_105829_create_user_bank_accounts_table.php | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/WalletController.php b/app/Http/Controllers/WalletController.php index b7849cc..eadffd5 100755 --- a/app/Http/Controllers/WalletController.php +++ b/app/Http/Controllers/WalletController.php @@ -646,7 +646,7 @@ INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON { $this->validate($request, [ 'id_user' => 'required|integer|exists:users,id', - 'id_operator' => 'required|integer|exists:operators,id', + 'id_operator' => 'required|integer|exists:operators_countries,id', 'id_wallet_network' => 'required|integer|exists:networks,id', 'lastname' => 'required|string', 'firstname' => 'required|string', @@ -674,7 +674,7 @@ INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON $user = User::findOrFail($request->id_user); $identification = $this->checkUserIdentification($user->id); - $operateur_country = OperatorsCountry::where('id_operator', $request->id_operator)->first(); + $operateur_country = OperatorsCountry::where('id', $request->id_operator)->first(); if (!$operateur_country) { return $this->errorResponse(trans('errors.bank_not_associated_with_network')); @@ -694,7 +694,7 @@ INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON } $exist_user_request_create_account = UserBankAccount::where('id_user', $request->id_user) - ->where('id_operator', $request->id_operator) + ->where('id_operator_country', $request->id_operator) ->first(); if (isset($exist_user_request_create_account)){ @@ -708,10 +708,11 @@ INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON return $this->errorResponse(trans('messages.user_already_has_bank_account_with_this_operator', ['user_lastname' => $user->lastname])); } } - + $bank_name = $network_bank->operators_country->operator->nom; + $bankAccount = new UserBankAccount(); $bankAccount->id_user = $user->id; - $bankAccount->id_operator = $request->id_operator; + $bankAccount->id_operator_country = $request->id_operator; $bankAccount->lastname = $request->lastname; $bankAccount->firstname = $request->firstname; $bankAccount->marital_name = $request->marital_name ?? 'null'; @@ -737,7 +738,6 @@ INNER JOIN countries c ON oc.id_country = c.id INNER JOIN type_operators top ON $bankAccount->created_at = date('Y-m-d H:i:s'); $bankAccount->updated_at = date('Y-m-d H:i:s'); $bankAccount->save(); - $bank_name = $network_bank->operators_country->operator->nom; // Envoi des informations à la banque partenaire (via API) // $payload = [ diff --git a/database/migrations/2025_11_13_105829_create_user_bank_accounts_table.php b/database/migrations/2025_11_13_105829_create_user_bank_accounts_table.php index 605d6b7..0f53c7e 100755 --- a/database/migrations/2025_11_13_105829_create_user_bank_accounts_table.php +++ b/database/migrations/2025_11_13_105829_create_user_bank_accounts_table.php @@ -19,8 +19,7 @@ class CreateUserBankAccountsTable extends Migration // Référence utilisateur $table->unsignedInteger('id_user'); - $table->unsignedInteger('id_operator') - ->comment('Identifiant de l’opérateur (banque partenaire)'); + $table->unsignedInteger('id_operator_country'); // Informations bancaires principales $table->string('account_number')->unique() @@ -65,7 +64,7 @@ class CreateUserBankAccountsTable extends Migration Schema::table('user_bank_accounts', function (Blueprint $table) { $table->foreign('id_user')->references('id')->on('users')->onDelete('cascade'); - $table->foreign('id_operator')->references('id')->on('operators')->onDelete('cascade'); + $table->foreign('id_operator_country')->references('id')->on('operators_countries')->onDelete('cascade'); }); }