From 711b28ed56a88bbe845119beb8a6fc30e6f0b4c0 Mon Sep 17 00:00:00 2001 From: azizi Date: Thu, 24 Sep 2020 18:48:00 +0330 Subject: [PATCH] solve some bugs and improve codes --- app/Console/Commands/ConvertUser.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/ConvertUser.php b/app/Console/Commands/ConvertUser.php index d85d952..6f96fc7 100644 --- a/app/Console/Commands/ConvertUser.php +++ b/app/Console/Commands/ConvertUser.php @@ -243,12 +243,27 @@ class ConvertUser extends Command $cellPhone = null; + foreach ($phones as $phone) + { + + $phone->tel = str_replace(' ','',$phone->tel); + + } + for( $i=0; $i <= count($phones)-1 ; $i++ ) { - if($phones[$i]->label == 'Mobile') + + $regex = '/^09[0,1,2,3,9]{1}[0-9]{8}$/'; + + $match = preg_match($regex,$phones[$i]->tel); + + if ($match == 1) { $cellPhone = $phones[$i]->tel; + break; + } + } @@ -263,6 +278,7 @@ class ConvertUser extends Command $userTableData = [ 'name' => $userData->brand_fa, + 'name_en' => $userData->brand_en, 'business_id' => 3, 'cell_number' => $cellPhone, 'detail' => json_encode($userTableDedails), @@ -283,7 +299,7 @@ class ConvertUser extends Command $newUserId = $this->insertRowToUsers($userTableData); $this->categoriesConfig($userData->category_id, $newUserId); $this->InsertAddress($userAddress, $userData->id,$newUserId); - $this->insertPhone($userData->phones , $newUserId); + $this->insertPhone($phones , $newUserId); $lastStatusId = $this->insertToClientStatuses($userData->status); $this->updateToUserStatus($newUserId,$lastStatusId); $count ++;