From 6c0c4dbbceaecce4a0ccdf8f8c8787efa7adea80 Mon Sep 17 00:00:00 2001 From: Djery-Tom Date: Mon, 6 Jul 2020 17:09:25 +0100 Subject: [PATCH] + Change structure of ID transaction --- .../iLinkTransactionController.php | 21 ++++++++++++++++++- app/Traits/Helper.php | 10 ++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/iLinkTransactionController.php b/app/Http/Controllers/iLinkTransactionController.php index 1950c77..64336a3 100755 --- a/app/Http/Controllers/iLinkTransactionController.php +++ b/app/Http/Controllers/iLinkTransactionController.php @@ -192,7 +192,7 @@ class iLinkTransactionController extends Controller 'net_final' => $this->toMoneyWithCurrency($montantDepot, $init_country, $request->final_country), 'fees' => $this->toMoney($frais + $taxe, $init_country), 'init_country' => $this->getCountryName($init_country), 'final_country' => $this->getCountryName($request->final_country), 'sender_code' => $user->user_code, 'receiver_code' => $transaction->id_destinataire]); - $this->sendMail($user->email, trans('messages.successful_transaction'), $message); +// $this->sendMail($user->email, trans('messages.successful_transaction'), $message); return $this->successResponse($message . trans('messages.sent_by_mail')); } } else { @@ -1183,4 +1183,23 @@ class iLinkTransactionController extends Controller shuffle($temp_array); return implode('', $temp_array); } + + private function getTransactionID(){ + do{ + $code=$this->generateTransactionCode(); + $result = collect(DB::select('SELECT * FROM wallet_ilink_transaction WHERE id_transaction = :code',['code'=>$code])); + $codeCorrect=sizeof($result)<0; + }while($codeCorrect); + return $code; + } + + private function generateTransactionCode($length = 12) { + $characters = '23456789abcdefghjkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ'; + $charactersLength = strlen($characters); + $randomString = ''; + for ($i = 0; $i < $length; $i++) { + $randomString .= $characters[rand(0, $charactersLength - 1)]; + } + return $randomString; + } } diff --git a/app/Traits/Helper.php b/app/Traits/Helper.php index 4e612e0..409bab2 100644 --- a/app/Traits/Helper.php +++ b/app/Traits/Helper.php @@ -131,11 +131,11 @@ trait Helper } - public function getTransactionID(){ - $d = new DateTime(); - $first = str_replace(['-',':'], '',$d->format("y-m-d H:i:s.u")); - return str_replace(' ' ,'.',$first); - } +// public function getTransactionID(){ +// $d = new DateTime(); +// $first = str_replace(['-',':'], '',$d->format("y-m-d H:i:s.u")); +// return str_replace(' ' ,'.',$first); +// } public function getCurrency($id_country){ $cc = CountriesCurrency::findOrFail($id_country);