diff --git a/app/Http/Controllers/CommissionController.php b/app/Http/Controllers/CommissionController.php index 48e3a2e..8120149 100755 --- a/app/Http/Controllers/CommissionController.php +++ b/app/Http/Controllers/CommissionController.php @@ -2,21 +2,16 @@ namespace App\Http\Controllers; -use App\Models\ConfigWallet; -use App\Models\Network; -use App\Models\NetworksAgent; use App\Models\TransfertCommissionTransaction; use App\Models\Wallet; -use App\Models\WalletTransaction; use App\Traits\ApiResponser; -use Illuminate\Http\Request; +use App\Traits\Helper; use Illuminate\Http\Response; -use Illuminate\Support\Facades\Date; -use Illuminate\Support\Facades\Mail; class CommissionController extends Controller { use ApiResponser; + use Helper; /** * Create a new controller instance. * @@ -42,7 +37,7 @@ class CommissionController extends Controller $transaction->balance_princ_final = $wallet->balance_princ; $transaction->balance_com_final = $wallet->balance_com; $transaction->id_wallet_ag = $wallet->id; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($wallet->networks_agent->network->country_id); $wallet->save(); $transaction->save(); diff --git a/app/Http/Controllers/CreditController.php b/app/Http/Controllers/CreditController.php index c803ba1..cd57781 100755 --- a/app/Http/Controllers/CreditController.php +++ b/app/Http/Controllers/CreditController.php @@ -42,6 +42,7 @@ class CreditController extends Controller $walletAgent = Wallet::where('id_networkAgent',$demand->network_agent_id)->firstOrFail(); $walletParrain = Wallet::findOrFail($walletAgentParrain->wallet_id); + $datetime = $this->getCurrentTime($walletAgent->networks_agent->network->country_id); if(isset($request->montant)){ $rules = [ @@ -55,7 +56,7 @@ class CreditController extends Controller $walletAgent->balance_princ += $request->montant; $walletParrain->balance_princ -= $request->montant; - DB::update('UPDATE demandeCredits SET montant = ? , `status` = \'1\' , date_modification = CURRENT_TIMESTAMP WHERE ( id = ? );',[$request->montant,$demand->id]); + DB::update('UPDATE demandeCredits SET montant = ? , `status` = \'1\' , date_modification = ? , date_creation = ? WHERE ( id = ? );', [$request->montant, $datetime, $datetime, $demand->id]); }else{ if($walletParrain->balance_princ < $demand->montant) return $this->errorResponse(trans('messages.princ_balance_inf_to_demand_amount'),Response::HTTP_UPGRADE_REQUIRED); @@ -63,7 +64,7 @@ class CreditController extends Controller $walletAgent->balance_princ += $demand->montant; $walletParrain->balance_princ -= $demand->montant; - DB::update('UPDATE demandeCredits SET `status` = \'1\' , date_modification = CURRENT_TIMESTAMP WHERE ( id = ? );',[$demand->id]); + DB::update('UPDATE demandeCredits SET `status` = \'1\' , date_modification = ? , date_creation = ? WHERE ( id = ? );', [$datetime, $datetime, $demand->id]); } $walletAgent->save(); diff --git a/app/Http/Controllers/HelperController.php b/app/Http/Controllers/HelperController.php index 56c8c00..468dd32 100755 --- a/app/Http/Controllers/HelperController.php +++ b/app/Http/Controllers/HelperController.php @@ -146,4 +146,10 @@ class HelperController extends Controller } return $this->successResponse($codes); } + + // Afficher l'heure en fonction du pays de l'utilisateur + public function getCurrentTimeB() + { + dd($this->getCurrentTime()); + } } diff --git a/app/Http/Controllers/NanoCreditController.php b/app/Http/Controllers/NanoCreditController.php index 95c3887..501db22 100755 --- a/app/Http/Controllers/NanoCreditController.php +++ b/app/Http/Controllers/NanoCreditController.php @@ -123,7 +123,7 @@ class NanoCreditController extends Controller $demande->id_user = $user->id; $demande->id_demande = $demande_credit->id_demande; $demande->id_agent = $walletHyper->agent_id; - $demande->date_creation = new \DateTime(); + $demande->date_creation = $this->getCurrentTime($init_country); $demande->type = 'nano_credit'; $demande->save(); @@ -141,7 +141,7 @@ class NanoCreditController extends Controller $walletHyper = Wallet::findOrFail($walletHyper->wallet_id); $walletUser = WalletsUser::where('idUser', $request->id_user)->firstOrFail(); - $demande_credit->date_validation = new \DateTime(); + $demande_credit->date_validation = $this->getCurrentTime($init_country); $demande_credit->date_remboursement_prevu = $demande_credit->date_validation->modify('+' . $request->duree_mois . ' month'); $demande_credit->etat = 'VALIDE'; @@ -173,6 +173,7 @@ class NanoCreditController extends Controller $montant_total = $demande_credit->montant + $demande_credit->interet + $demande_credit->taxe; $demande_credit->id_demande = $this->getNanoCreditDemandID(); + $demande_credit->date_creation = $this->getCurrentTime($init_country); $demande_credit->save(); $message = trans('messages.successful_user_individual_nano_credit_demand', @@ -345,7 +346,7 @@ class NanoCreditController extends Controller return $this->errorResponse(trans('errors.insufficient_balance')); - $demande_credit->date_validation = new \DateTime(); + $demande_credit->date_validation = $this->getCurrentTime($agent_country); $demande_credit->date_remboursement_prevu = $demande_credit->date_validation->modify('+' . $demande_credit->duree_mois . ' month'); $demande_credit->etat = 'VALIDE'; $demande_credit->id_wallet_agent = $walletAgent->id; @@ -489,7 +490,7 @@ class NanoCreditController extends Controller $saving->fill($request->all()); $saving->id_network = $config->id_network; $sumFees = 0; - $saving->date_creation = new \DateTime(); + $saving->date_creation = $this->getCurrentTime($init_country); if ($request->type == 'blocked') { $taxes = array_values(array_filter($config->taxes->all(), function ($tax) { return $tax->categorie == 'epargne'; @@ -573,7 +574,7 @@ class NanoCreditController extends Controller $user->balance_epargne -= $montant_total; $walletUser->balance += $montant_total; $saving->etat = 'CASSE'; - $saving->date_cassation = new \DateTime(); + $saving->date_cassation = $this->getCurrentTime($init_country); $user->save(); $walletUser->save(); diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 072af1e..e6692b1 100755 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -10,13 +10,14 @@ use App\Models\Wallet; use App\Models\WalletAgent; use App\Models\WalletTransaction; use App\Traits\ApiResponser; +use App\Traits\Helper; use Illuminate\Http\Request; use Illuminate\Http\Response; -use Illuminate\Support\Facades\DB; class TransactionController extends Controller { use ApiResponser; + use Helper; /** * Create a new controller instance. @@ -173,7 +174,7 @@ class TransactionController extends Controller } - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($walletAgent->networks_agent->network->country_id); $transaction->statut = 1; $walletAgent->save(); $walletSuperviseur->save(); diff --git a/app/Http/Controllers/TransmittingNetworksController.php b/app/Http/Controllers/TransmittingNetworksController.php index 19db76c..e6c8cfe 100755 --- a/app/Http/Controllers/TransmittingNetworksController.php +++ b/app/Http/Controllers/TransmittingNetworksController.php @@ -126,6 +126,7 @@ class TransmittingNetworksController extends Controller $transaction->commission_hyp = $transaction->commission_hyp_final_country = $request->montant_commission; $transaction->status_reseau_payeur = 'TRAITEE'; + $transaction->date = $this->getCurrentTimeByCountryCode($initNetwork->country->code_country); $transaction->save(); $message = trans('messages.wallet_incoming_payment_message', @@ -159,7 +160,7 @@ class TransmittingNetworksController extends Controller $transaction->commission_ag = floatval($request->montant_commission * $configRecipient->taux_com_ag_envoi_cash / 100); $transaction->commission_sup = floatval($request->montant_commission * $configRecipient->taux_com_sup_envoi_cash / 100); $transaction->commission_hyp = $transaction->commission_hyp_final_country = floatval($request->montant_commission * $configRecipient->taux_com_hyp_envoi_cash / 100); - + $transaction->date = $this->getCurrentTimeByCountryCode($initNetwork->country->code_country); $transaction->save(); $message = trans('messages.cash_incoming_payment_message', diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 25250a8..9b3ced8 100755 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -46,6 +46,7 @@ class UserController extends Controller $identification->fill($request->all()); $identification->id_user = $user->id; $identification->status = 0; + $identification->createdAt = $this->getCurrentTimeByCountryCode($user->network->country->code_country); $identification->save(); $this->sendMail($user->email, trans('messages.successful_identification', ['name' => $identification->lastname . ' ' . $identification->firstname]), diff --git a/app/Http/Controllers/UserGroupController.php b/app/Http/Controllers/UserGroupController.php index 756411e..328bd0a 100755 --- a/app/Http/Controllers/UserGroupController.php +++ b/app/Http/Controllers/UserGroupController.php @@ -110,19 +110,19 @@ class UserGroupController extends Controller return $resp3; $group->id_createur = $request->id_user; - $group->date_creation = new \DateTime(); + $group->date_creation = $this->getCurrentTime($init_country); $group->nombre_validation = 0; $group->actif = false; $group->nombre_utilisateurs = 1; $group->code_groupe = $this->getGroupID(); $group->save(); $user->group_id = $group->id; - $user->date_adhesion = new \DateTime(); + $user->date_adhesion = $group->date_creation; $user->save(); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor1, $request->code_sponsor1, $user); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor2, $request->code_sponsor2, $user); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor3, $request->code_sponsor3, $user); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor1, $request->code_sponsor1, $user, $init_country); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor2, $request->code_sponsor2, $user, $init_country); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor3, $request->code_sponsor3, $user, $init_country); return $this->successResponse(trans('messages.successful_user_group_created')); @@ -172,11 +172,11 @@ class UserGroupController extends Controller } $sponsor->group_id = $group->id; - $sponsor->date_adhesion = new \DateTime(); + $sponsor->date_adhesion = $this->getCurrentTimeByCountryCode($sponsor->network->country->code_country); $sponsor->save(); $group->save(); $demande->statut = true; - $demande->date_validation = new \DateTime(); + $demande->date_validation = $sponsor->date_adhesion; $demande->save(); // Notififier le createur $data = new \stdClass(); @@ -209,7 +209,7 @@ class UserGroupController extends Controller $group = UsersGroup::findOrFail($demande->id_group); $demande->statut = 2; - $demande->date_validation = new \DateTime(); + $demande->date_validation = $this->getCurrentTimeByCountryCode($sponsor->network->country->code_country); $demande->save(); // Notififier le createur $data = new \stdClass(); @@ -335,15 +335,15 @@ class UserGroupController extends Controller $group->date_activation = null; if (isset($prevSponsor1)) { $prevSponsor1->save(); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor1, $request->code_sponsor1, $user); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor1, $request->code_sponsor1, $user, $init_country); } if (isset($prevSponsor2)) { $prevSponsor2->save(); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor2, $request->code_sponsor2, $user); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor2, $request->code_sponsor2, $user, $init_country); } if (isset($prevSponsor3)) { $prevSponsor3->save(); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor3, $request->code_sponsor3, $user); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor3, $request->code_sponsor3, $user, $init_country); } $group->save(); @@ -351,12 +351,12 @@ class UserGroupController extends Controller } - private function sendNotificationToSponsor($id_group, $id_sponsor, $sponsor_code, User $sender, $type = 'creation') + private function sendNotificationToSponsor($id_group, $id_sponsor, $sponsor_code, User $sender, $init_country, $type = 'creation') { $demande = new UsersGroupsDemandesValidation(); $demande->id_group = $id_group; $demande->id_sponsor = $id_sponsor; - $demande->date_creation = new \DateTime(); + $demande->date_creation = $this->getCurrentTime($init_country); $demande->statut = false; $demande->type = $type; @@ -443,7 +443,7 @@ ug.date_creation as date_creation_groupe , ug.createur , ug.sponsor1 , ug.sponso return $identfication; // Notifier le sponsor - $this->sendNotificationToSponsor($group->id, $sponsor->id, $sponsor->user_code, $user, 'adhesion'); + $this->sendNotificationToSponsor($group->id, $sponsor->id, $sponsor->user_code, $user, $country_user, 'adhesion'); return $this->successResponse(trans('messages.successful_group_membership_request')); } @@ -460,13 +460,13 @@ ug.date_creation as date_creation_groupe , ug.createur , ug.sponsor1 , ug.sponso if ($user->group_id) return $this->errorResponse(trans('errors.user_already_member_of_group')); $user->group_id = $group->id; - $user->date_adhesion = new \DateTime(); + $user->date_adhesion = $this->getCurrentTimeByCountryCode($sponsor->network->country->code_country); $user->save(); ++$group->nombre_utilisateurs; $group->save(); $demande->statut = true; - $demande->date_validation = new \DateTime(); + $demande->date_validation = $user->date_adhesion; $demande->save(); // Notififier l'utilisateur $data = new \stdClass(); @@ -487,13 +487,15 @@ ug.date_creation as date_creation_groupe , ug.createur , ug.sponsor1 , ug.sponso 'id_user' => 'required|integer|min:0|not_in:0' ]); + $user = User::findOrFail($request->id_user); + $country_user = $user->network->country->id; $group = UsersGroup::where('code_groupe', $request->code_groupe)->firstOrFail(); if ($group->id_createur != $request->id_user) return $this->errorResponse(trans('errors.not_group_creator')); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor1, $group->sponsor1->user_code, $group->createur, 'suppression'); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor2, $group->sponsor2->user_code, $group->createur, 'suppression'); - $this->sendNotificationToSponsor($group->id, $group->id_sponsor3, $group->sponsor3->user_code, $group->createur, 'suppression'); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor1, $group->sponsor1->user_code, $group->createur, $country_user, 'suppression'); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor2, $group->sponsor2->user_code, $group->createur, $country_user, 'suppression'); + $this->sendNotificationToSponsor($group->id, $group->id_sponsor3, $group->sponsor3->user_code, $group->createur, $country_user, 'suppression'); return $this->successResponse(trans('messages.successful_user_group_deleted')); @@ -523,7 +525,7 @@ ug.date_creation as date_creation_groupe , ug.createur , ug.sponsor1 , ug.sponso } $group->save(); $demande->statut = true; - $demande->date_validation = new \DateTime(); + $demande->date_validation = $this->getCurrentTimeByCountryCode($sponsor->network->country->code_country); $demande->save(); // Notififier le createur $data = new \stdClass(); @@ -602,7 +604,7 @@ ug.date_creation , ug.createur , ug.sponsor1 , ug.sponsor2 , ug.sponsor3, ug.cou $walletHyper->balance_princ -= $demande_credit->montant; $demande->statut = true; - $demande->date_validation = new \DateTime(); + $demande->date_validation = $this->getCurrentTimeByCountryCode($user->network->country->code_country); $user->save(); $walletUser->save(); $walletHyper->save(); diff --git a/app/Http/Controllers/WalletController.php b/app/Http/Controllers/WalletController.php index b52aa5d..ba0a2b6 100755 --- a/app/Http/Controllers/WalletController.php +++ b/app/Http/Controllers/WalletController.php @@ -30,7 +30,7 @@ class WalletController extends Controller public function activated($id_agent) { - $networks = DB::select('SELECT ne.name as network , cc.name AS country, cc.currency_code, w.id, w.balance_princ , w.balance_com, w.created_date, cw.type, + $networks = DB::select('SELECT ne.name as network , cc.name AS country, cc.code_country, cc.currency_code, w.id, w.balance_princ , w.balance_com, w.created_date, cw.type, na.id AS id_networkAgent , cw.taux_com_client_depot , na.id AS id_networkAgent , cg.category FROM agents ag INNER JOIN networks_agents na ON ag.id=na.agent_id INNER JOIN codeGenerer cg ON cg.id=na.codeGenerer_id INNER JOIN networks ne ON ne.id=na.network_id INNER JOIN configWallet cw ON ne.id = cw.id_network INNER JOIN countries_currencies cc ON ne.country_id=cc.id LEFT JOIN wallets w ON na.id = w.id_networkAgent WHERE ag.id= :id AND network_id IN ( @@ -45,7 +45,8 @@ class WalletController extends Controller $category = $network->category; // Create wallet if is not exist if (!$network->id) { - DB::insert('INSERT INTO wallets (id_networkAgent) VALUES (?);', [$network->id_networkAgent]); + $datetime = $this->getCurrentTimeByCountryCode($network->code_country); + DB::insert('INSERT INTO wallets (id_networkAgent , created_date) VALUES (? , ?);', [$network->id_networkAgent, $datetime]); $reload = true; } } diff --git a/app/Http/Controllers/iLinkTransactionController.php b/app/Http/Controllers/iLinkTransactionController.php index ab4e91a..620e6b8 100755 --- a/app/Http/Controllers/iLinkTransactionController.php +++ b/app/Http/Controllers/iLinkTransactionController.php @@ -271,6 +271,7 @@ class iLinkTransactionController extends Controller $walletUser->save(); if (isset($reseauPayeur)) $reseauPayeur->save(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->save(); $message = trans('messages.successful_user_send_to_wallet', ['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), 'net_init' => $this->toMoney($montantDepot, $init_country), @@ -330,6 +331,7 @@ class iLinkTransactionController extends Controller $walletHyperviseur->save(); $walletUser->save(); $transaction->id_transaction = $this->getTransactionID(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->save(); $message = trans('messages.successful_user_send_to_cart', ['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), @@ -422,7 +424,7 @@ class iLinkTransactionController extends Controller $reseauPayeur->save(); $walletHyperviseur->save(); $walletUser->save(); - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->status_retrait = 0; $transaction->save(); $message = trans('messages.successful_user_send_to_cash', @@ -491,6 +493,7 @@ class iLinkTransactionController extends Controller $transaction->country = $network_bank->network->country->name; $transaction->id_bank = $request->id_bank; $transaction->iban = $request->iban; + $transaction->date = $this->getCurrentTime($init_country); // $walletUser->save(); $transaction->id_transaction = $this->getTransactionID(); // $transaction->save(); @@ -543,7 +546,7 @@ class iLinkTransactionController extends Controller $walletHyperviseur->save(); $walletUser->save(); - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->status_retrait = 0; $transaction->save(); $message = trans('messages.successful_user_remove_from_wallet_to_cash', @@ -603,6 +606,7 @@ class iLinkTransactionController extends Controller $walletHyperviseur->save(); $walletUser->save(); $transaction->id_transaction = $this->getTransactionID(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->save(); $message = trans('messages.successful_user_remove_from_cart_to_wallet', ['id_transaction' => $transaction->id_transaction, 'amount' => $this->toMoney($transaction->montant, $init_country), @@ -667,7 +671,7 @@ class iLinkTransactionController extends Controller $walletHyperviseur->balance_com += $transaction->commission_hyp; $transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->frais = $frais; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->status_retrait = 0; $walletHyperviseur->save(); $transaction->id_transaction = $this->getTransactionID(); @@ -741,8 +745,8 @@ class iLinkTransactionController extends Controller $transactionRetrait->status_retrait = $transactionRetrait->commission_banque = $transactionRetrait->code_retrait_salt = $transactionRetrait->encrypted_code_retrait = null; $transactionRetrait->frais = $transactionRetrait->taxe = 0; $transaction->status_retrait = 1; - $transaction->date_retrait = new \DateTime(); - $transactionRetrait->date = new \DateTime(); + $transaction->date_retrait = $this->getCurrentTime($init_country); + $transaction->date = $this->getCurrentTime($init_country); //Si la transaction provient du reseau emetteur if ($transaction->from_network_emetteur) { $transaction->status_reseau_payeur = 'TRAITEE'; @@ -828,7 +832,7 @@ class iLinkTransactionController extends Controller $transaction->id_wallet_sup = $walletSuperviseur->id; $transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->frais = $frais; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $walletAgent->save(); $walletSuperviseur->save(); $walletHyperviseur->save(); @@ -878,7 +882,7 @@ class iLinkTransactionController extends Controller $transaction->commission_hyp = $commisionHyper; $transaction->taxe = $taxe; $transaction->frais = $frais; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $walletUser->save(); $walletAgent->save(); $walletSuperviseur->save(); @@ -942,7 +946,7 @@ class iLinkTransactionController extends Controller $transaction->commission_hyp = $commisionHyper; $transaction->taxe = $taxe; $transaction->frais = $frais; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $walletAgent->save(); $walletSuperviseur->save(); @@ -1022,7 +1026,7 @@ class iLinkTransactionController extends Controller $transaction->id_wallet_sup = $walletSuperviseur->id; $transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->frais = $frais; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $walletAgent->save(); $walletSuperviseur->save(); $walletHyperviseur->save(); @@ -1118,7 +1122,7 @@ class iLinkTransactionController extends Controller $walletAgent->balance_princ -= $transaction->montant; $transaction->frais = $frais; $transaction->taxe = $taxe; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->status_retrait = 0; if (isset($reseauPayeur)) $reseauPayeur->save(); @@ -1184,7 +1188,7 @@ class iLinkTransactionController extends Controller $transaction->id_wallet_ag = $walletAgent->id; $transaction->id_wallet_sup = $walletSuperviseur->id; $transaction->frais = $frais; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->bank = $network_bank->operators_country->operator->nom; $transaction->country = $network_bank->network->country->name; $transaction->id_bank = $request->id_bank; @@ -1286,7 +1290,7 @@ class iLinkTransactionController extends Controller $transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->frais = $frais; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->operator = $network_bank->operators_country->operator->nom; $type_operator = $network_bank->operators_country->operator->type_operator; $transaction->type_operator = app()->isLocale('en') ? $type_operator->description_en : $type_operator->description_fr; @@ -1363,7 +1367,7 @@ class iLinkTransactionController extends Controller $transaction->id_wallet_hyp = $walletHyperviseur->id; $transaction->frais = $frais; - $transaction->date = new \DateTime(); + $transaction->date = $this->getCurrentTime($init_country); $transaction->bank = $user->bank->operators_country->operator->nom; $transaction->country = $user->bank->network->country->name; $transaction->id_bank = $user->id_bank_country; diff --git a/app/Traits/Helper.php b/app/Traits/Helper.php index d2617ca..5c6969a 100644 --- a/app/Traits/Helper.php +++ b/app/Traits/Helper.php @@ -373,7 +373,7 @@ trait Helper $walletHyper->save(); } - $demande_credit->date_remboursement = new \DateTime(); + $demande_credit->date_remboursement = $this->getCurrentTime($init_country); $demande_credit->montant = $resteARembourser; $walletUser->save(); @@ -396,6 +396,7 @@ trait Helper } + //Envoyer la trame au reseau payeur externe public function sendFrame($paying_network_url, WalletIlinkTransaction $transaction, $code_retrait = null) { $client = new \GuzzleHttp\Client(); @@ -478,4 +479,22 @@ trait Helper } + // Obtenir l'heure en fonction du pays de l'utilisateur + public function getCurrentTime($id_country) + { + $country = Country::find($id_country); + $country_code = isset($country) ? $country->code_country : 'GA'; + $timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $country_code); + $date = (sizeof($timezone) > 0) ? new \DateTime('now', new \DateTimeZone($timezone[0])) : new \DateTime(); + return $date->format('Y-m-d H:i:s'); + } + +// Obtenir l'heure en fonction du code du pays de l'utilisateur + public function getCurrentTimeByCountryCode($country_code = 'GA') + { + $timezone = \DateTimeZone::listIdentifiers(\DateTimeZone::PER_COUNTRY, $country_code); + $date = (sizeof($timezone) > 0) ? new \DateTime('now', new \DateTimeZone($timezone[0])) : new \DateTime(); + return $date->format('Y-m-d H:i:s'); + } + } diff --git a/composer.lock b/composer.lock index 0ce951a..db1b932 100755 --- a/composer.lock +++ b/composer.lock @@ -2201,29 +2201,31 @@ }, { "name": "nesbot/carbon", - "version": "2.32.1", + "version": "2.41.5", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "ecb525c766deb3bbbb6a0082ea0e41d3d9ae477c" + "reference": "c4a9caf97cfc53adfc219043bcecf42bc663acee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ecb525c766deb3bbbb6a0082ea0e41d3d9ae477c", - "reference": "ecb525c766deb3bbbb6a0082ea0e41d3d9ae477c", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/c4a9caf97cfc53adfc219043bcecf42bc663acee", + "reference": "c4a9caf97cfc53adfc219043bcecf42bc663acee", "shasum": "" }, "require": { "ext-json": "*", "php": "^7.1.8 || ^8.0", + "symfony/polyfill-mbstring": "^1.0", "symfony/translation": "^3.4 || ^4.0 || ^5.0" }, "require-dev": { "doctrine/orm": "^2.7", "friendsofphp/php-cs-fixer": "^2.14 || ^3.0", - "kylekatarnls/multi-tester": "^1.1", - "phpmd/phpmd": "^2.8", - "phpstan/phpstan": "^0.11", + "kylekatarnls/multi-tester": "^2.0", + "phpmd/phpmd": "^2.9", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.35", "phpunit/phpunit": "^7.5 || ^8.0", "squizlabs/php_codesniffer": "^3.4" }, @@ -2233,12 +2235,18 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "2.x-dev", + "dev-3.x": "3.x-dev" }, "laravel": { "providers": [ "Carbon\\Laravel\\ServiceProvider" ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] } }, "autoload": { @@ -2268,7 +2276,17 @@ "datetime", "time" ], - "time": "2020-03-26T13:04:10+00:00" + "funding": [ + { + "url": "https://opencollective.com/Carbon", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "type": "tidelift" + } + ], + "time": "2020-10-23T06:02:30+00:00" }, { "name": "nikic/fast-route", @@ -3852,20 +3870,20 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.15.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac" + "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/81ffd3a9c6d707be22e3012b827de1c9775fc5ac", - "reference": "81ffd3a9c6d707be22e3012b827de1c9775fc5ac", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", + "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-mbstring": "For best performance" @@ -3873,7 +3891,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-main": "1.20-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -3907,7 +3929,21 @@ "portable", "shim" ], - "time": "2020-03-09T19:04:49+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-23T14:02:19+00:00" }, { "name": "symfony/polyfill-php72", @@ -4022,6 +4058,86 @@ ], "time": "2020-02-27T09:26:54+00:00" }, + { + "name": "symfony/polyfill-php80", + "version": "v1.20.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/e70aa8b064c5b72d3df2abd5ab1e90464ad009de", + "reference": "e70aa8b064c5b72d3df2abd5ab1e90464ad009de", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.20-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-23T14:02:19+00:00" + }, { "name": "symfony/process", "version": "v5.0.7", @@ -4131,21 +4247,22 @@ }, { "name": "symfony/translation", - "version": "v5.0.7", + "version": "v5.1.8", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "99b831770e10807dca0979518e2c89edffef5978" + "reference": "27980838fd261e04379fa91e94e81e662fe5a1b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/99b831770e10807dca0979518e2c89edffef5978", - "reference": "99b831770e10807dca0979518e2c89edffef5978", + "url": "https://api.github.com/repos/symfony/translation/zipball/27980838fd261e04379fa91e94e81e662fe5a1b6", + "reference": "27980838fd261e04379fa91e94e81e662fe5a1b6", "shasum": "" }, "require": { - "php": "^7.2.5", + "php": ">=7.2.5", "symfony/polyfill-mbstring": "~1.0", + "symfony/polyfill-php80": "^1.15", "symfony/translation-contracts": "^2" }, "conflict": { @@ -4175,11 +4292,6 @@ "symfony/yaml": "" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, "autoload": { "psr-4": { "Symfony\\Component\\Translation\\": "" @@ -4204,24 +4316,38 @@ ], "description": "Symfony Translation Component", "homepage": "https://symfony.com", - "time": "2020-03-27T16:56:45+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-24T12:01:57+00:00" }, { "name": "symfony/translation-contracts", - "version": "v2.0.1", + "version": "v2.3.0", "source": { "type": "git", "url": "https://github.com/symfony/translation-contracts.git", - "reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed" + "reference": "e2eaa60b558f26a4b0354e1bbb25636efaaad105" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/8cc682ac458d75557203b2f2f14b0b92e1c744ed", - "reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/e2eaa60b558f26a4b0354e1bbb25636efaaad105", + "reference": "e2eaa60b558f26a4b0354e1bbb25636efaaad105", "shasum": "" }, "require": { - "php": "^7.2.5" + "php": ">=7.2.5" }, "suggest": { "symfony/translation-implementation": "" @@ -4229,7 +4355,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.0-dev" + "dev-master": "2.3-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" } }, "autoload": { @@ -4261,7 +4391,21 @@ "interoperability", "standards" ], - "time": "2019-11-18T17:27:11+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-09-28T13:05:58+00:00" }, { "name": "symfony/var-dumper", @@ -4795,6 +4939,7 @@ "faker", "fixtures" ], + "abandoned": true, "time": "2019-12-12T13:22:17+00:00" }, { diff --git a/routes/web.php b/routes/web.php index c643e3f..d676374 100755 --- a/routes/web.php +++ b/routes/web.php @@ -14,7 +14,7 @@ //$router->get('/', function () use ($router) { // return $router->app->version(); //}); - +$router->get('time', 'HelperController@getCurrentTimeB'); $router->group(['prefix' => '', 'middleware' => 'auth'], function () use ($router) { // Helper routes $router->post('receivePayment', 'TransmittingNetworksController@receivePayment');