From ed12235c9679654095113521c6cb43b03c2ca272 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Fri, 20 Nov 2020 17:25:54 +0100 Subject: [PATCH] + Translate missing states of requests --- app/Http/Controllers/NanoCreditController.php | 36 ++++++++++++------- app/Http/Controllers/WalletController.php | 28 ++++++++++----- resources/lang/en/states.php | 15 ++++++++ resources/lang/fr/states.php | 15 ++++++++ routes/web.php | 4 +-- 5 files changed, 76 insertions(+), 22 deletions(-) create mode 100755 resources/lang/en/states.php create mode 100755 resources/lang/fr/states.php diff --git a/app/Http/Controllers/NanoCreditController.php b/app/Http/Controllers/NanoCreditController.php index e6e9f30..0c0b267 100755 --- a/app/Http/Controllers/NanoCreditController.php +++ b/app/Http/Controllers/NanoCreditController.php @@ -158,8 +158,8 @@ class NanoCreditController extends Controller $message = trans('messages.successful_user_group_nano_credit_demand', ['id_demand' => $demande_credit->id_demande, 'amount' => $this->toMoney($montant_total, $init_country), 'duration' => $demande_credit->duree_mois, - 'net' => $this->toMoney($demande_credit->montant, $init_country), 'fees' => $this->toMoney($demande_credit->interet , $init_country), - 'date' => $demande_credit->date_remboursement_prevu , 'tax' => $this->toMoney($demande_credit->taxe, $init_country)]); + 'net' => $this->toMoney($demande_credit->montant, $init_country), 'fees' => $this->toMoney($demande_credit->interet, $init_country), + 'date' => $demande_credit->date_remboursement_prevu, 'tax' => $this->toMoney($demande_credit->taxe, $init_country)]); $this->sendMail($user->email, trans('messages.successful_nano_credit_demand'), $message); return $this->successResponse($message . trans('messages.sent_by_mail')); } @@ -197,7 +197,11 @@ class NanoCreditController extends Controller // Supprimer les underscore sur les etats $merge = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + if (isset($demand->type)) + $demand->type = trans('states.' . $demand->type); + if (isset($demand->type_caution)) + $demand->type_caution = trans('states.' . $demand->type_caution); return $demand; }, array_merge($demandes, $savings)); @@ -213,7 +217,8 @@ class NanoCreditController extends Controller $demandes = DB::select('SELECT i.montant , i.user as destinataire, i.* FROM infos_users_demandes_credits i WHERE i.id_user = :id ORDER BY i.date_creation DESC;', ['id' => $id_user]); $result = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type_caution = trans('states.' . $demand->type_caution); return $demand; }, $demandes); return $this->successResponse($result); @@ -225,7 +230,8 @@ class NanoCreditController extends Controller $demandes = DB::select("SELECT type_caution , etat , montant , date_creation , id_demande , montant_rembourse ,partiellement_rembourse , duree_mois , interet , taxe , date_validation ,date_remboursement_prevu, retrait_cash , agent FROM infos_users_demandes_credits i WHERE i.id_user = :id AND i.etat = 'VALIDE' ORDER BY date_creation DESC;", ['id' => $id_user]); $result = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type_caution = trans('states.' . $demand->type_caution); return $demand; }, $demandes); return $this->successResponse($result); @@ -236,7 +242,8 @@ class NanoCreditController extends Controller $demandes = DB::select('SELECT i.montant , i.user as destinataire, i.* FROM infos_users_demandes_credits i WHERE i.id_wallet_agent = :id ORDER BY i.date_creation DESC;' , ['id' => $id_wallet_agent]); $result = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type_caution = trans('states.' . $demand->type_caution); return $demand; }, $demandes); return $this->successResponse($result); @@ -246,7 +253,8 @@ class NanoCreditController extends Controller { $savings = DB::select('SELECT i.montant , i.user as destinataire, i.* FROM infos_users_epargnes i WHERE i.id_user = :id ORDER BY i.date_creation DESC;', ['id' => $id_user]); $result = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type = trans('states.' . $demand->type); return $demand; }, $savings); return $this->successResponse($result); @@ -300,7 +308,8 @@ class NanoCreditController extends Controller { $savings = DB::select("SELECT i.type , etat, montant, montant_retire , date_creation , id_epargne , duree_mois , interet , taxe , date_fin FROM infos_users_epargnes i WHERE i.id_user = :id AND i.etat = 'EN_COURS' ORDER BY i.date_creation DESC;", ['id' => $id_user]); $result = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type = trans('states.' . $demand->type);//trans('states.'.$demand->etat); return $demand; }, $savings); return $this->successResponse($result); @@ -427,7 +436,7 @@ class NanoCreditController extends Controller public function getDurations(Request $request) { - $this->validate($request , [ + $this->validate($request, [ 'type' => 'required|in:nano_credit,epargne', 'id_user' => 'required|integer|min:0|not_in:0', ]); @@ -599,7 +608,8 @@ class NanoCreditController extends Controller { $demand = UsersDemandesCredit::where('id_demande', $id_demand)->first(); if ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type_caution = trans('states.' . $demand->type_caution); return $this->successResponse($demand); } else { return $this->errorResponse(trans('errors.nano_credit_not_found')); @@ -610,14 +620,16 @@ class NanoCreditController extends Controller { $demand = UsersEpargne::where('id_epargne', $id_saving)->first(); if ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type = trans('states.' . $demand->type); return $this->successResponse($demand); } else { return $this->errorResponse(trans('errors.savings_not_found')); } } - public function getNanoCreditAccount($id_user){ + public function getNanoCreditAccount($id_user) + { $user = User::findOrFail($id_user); $data = new \stdClass(); $data->balance_credit = $user->balance_credit; diff --git a/app/Http/Controllers/WalletController.php b/app/Http/Controllers/WalletController.php index ba0a2b6..cd4c0f2 100755 --- a/app/Http/Controllers/WalletController.php +++ b/app/Http/Controllers/WalletController.php @@ -168,7 +168,11 @@ class WalletController extends Controller // Supprimer les underscore sur les etats $merge = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + if (isset($demand->type)) + $demand->type = trans('states.' . $demand->type); + if (isset($demand->type_caution)) + $demand->type_caution = trans('states.' . $demand->type_caution); return $demand; }, array_merge($demandes, $savings)); @@ -179,10 +183,11 @@ class WalletController extends Controller return $this->successResponse($this->arrayPaginator($result, $request)); } - public function superHistory($id_wallet, Request $request) + public function superHistory($agent_code, Request $request) { - $walletSup = WalletAgent::where('wallet_id', $id_wallet)->firstOrFail(); + $walletSup = WalletAgent::where('codeMembre', $agent_code)->firstOrFail(); + $id_wallet = $walletSup->wallet_id; $demandes = DB::select("SELECT 'N' as type_historique , i.montant ,i.user as destinataire , i.* FROM infos_users_demandes_credits i WHERE codeParrain = :code ;", ['code' => $walletSup->codeMembre]); @@ -223,7 +228,8 @@ class WalletController extends Controller // Supprimer les underscore sur les etats $demandes_mapped = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type_caution = trans('states.' . $demand->type_caution); return $demand; }, $demandes); @@ -281,7 +287,11 @@ class WalletController extends Controller // Supprimer les underscore sur les etats $merge = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + if (isset($demand->type)) + $demand->type = trans('states.' . $demand->type); + if (isset($demand->type_caution)) + $demand->type_caution = trans('states.' . $demand->type_caution); return $demand; }, array_merge($demandes, $savings)); @@ -292,10 +302,11 @@ class WalletController extends Controller return $this->successResponse($result); } - public function allSuperHistory($id_wallet) + public function allSuperHistory($agent_code) { - $walletSup = WalletAgent::where('wallet_id', $id_wallet)->firstOrFail(); + $walletSup = WalletAgent::where('codeMembre', $agent_code)->firstOrFail(); + $id_wallet = $walletSup->wallet_id; $demandes = DB::select("SELECT 'N' as type_historique, i.montant , i.user as destinataire , i.* FROM infos_users_demandes_credits i WHERE codeParrain = :code ;", ['code' => $walletSup->codeMembre]); @@ -342,7 +353,8 @@ class WalletController extends Controller // Supprimer les underscore sur les etats $demandes_mapped = array_map(function ($demand) { - $demand->etat = str_replace('_', ' ', $demand->etat); + $demand->etat = trans('states.' . $demand->etat); + $demand->type_caution = trans('states.' . $demand->type_caution); return $demand; }, $demandes); diff --git a/resources/lang/en/states.php b/resources/lang/en/states.php new file mode 100755 index 0000000..2b101bc --- /dev/null +++ b/resources/lang/en/states.php @@ -0,0 +1,15 @@ + "CURRENT", + "CASSE" => "BROKEN", + "EN_ATTENTE_DE_VALIDATION" => "PENDING VALIDATION", + "REMBOURSE" => "REFUND", + "NON_VALIDE" => "INVALID", + "VALIDE" => "VALID", + "SIMPLE" => "SIMPLE", + "BLOQUE" => "BLOCKED", + "NON_TRAITEE" => "NOT TREATED", + "TRAITEE" => "TREATED", + "groupe" => 'GROUP', + "individuel" => "INDIVIDUAL" +]; diff --git a/resources/lang/fr/states.php b/resources/lang/fr/states.php new file mode 100755 index 0000000..a347adb --- /dev/null +++ b/resources/lang/fr/states.php @@ -0,0 +1,15 @@ + "EN COURS", + "CASSE" => "CASSÉE", + "EN_ATTENTE_DE_VALIDATION" => "EN ATTENTE DE VALIDATION", + "REMBOURSE" => "REMBOURSE", + "NON_VALIDE" => "NON VALIDE", + "VALIDE" => "VALIDE", + "SIMPLE" => "SIMPLE", + "BLOQUE" => "BLOQUÉE", + "NON_TRAITEE" => "NON_TRAITÉE", + "TRAITEE" => "TRAITÉE", + "groupe" => 'GROUPE', + "individuel" => "INDIVIDUEL" +]; diff --git a/routes/web.php b/routes/web.php index 842bdb3..88c0a2f 100755 --- a/routes/web.php +++ b/routes/web.php @@ -60,10 +60,10 @@ $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($route //Les historiques globals des hyperviseur et superviseur $router->get('hyper_history/{id_network}', 'WalletController@hyperHistory'); - $router->get('super_history/{id_wallet}', 'WalletController@superHistory'); + $router->get('super_history/{agent_code}', 'WalletController@superHistory'); // Routes sans pagination $router->get('all_hyper_history/{id_network}', 'WalletController@allHyperHistory'); - $router->get('all_super_history/{id_wallet}', 'WalletController@allSuperHistory'); + $router->get('all_super_history/{agent_code}', 'WalletController@allSuperHistory'); // Wallets users iLink $router->group(['prefix' => '/users'], function () use ($router) {