+ Create wallet if is not exist while fetch wallets

This commit is contained in:
DJERY-TOM 2020-05-05 09:27:08 +01:00
parent 43fde01352
commit 3cc0afd190
1 changed files with 13 additions and 0 deletions

View File

@ -30,6 +30,19 @@ class WalletController extends Controller
INNER JOIN countries ON ne.country_id=countries.id LEFT JOIN wallets w ON na.id = w.id_networkAgent WHERE ag.id= :id AND network_id IN ( INNER JOIN countries ON ne.country_id=countries.id LEFT JOIN wallets w ON na.id = w.id_networkAgent WHERE ag.id= :id AND network_id IN (
SELECT networks.id FROM networks LEFT JOIN configWallet ON configWallet.id_network = networks.id WHERE status = 1 AND id_network IS NOT NULL)', ['id' => $id_agent]); SELECT networks.id FROM networks LEFT JOIN configWallet ON configWallet.id_network = networks.id WHERE status = 1 AND id_network IS NOT NULL)', ['id' => $id_agent]);
// Create wallet if is not exist
if($networks){
$reload = false;
$id = $id_agent;
foreach ($networks as $network){
if(!$network->id){
DB::insert('INSERT INTO wallets (id_networkAgent) VALUES (?);', [$network->id_networkAgent]);
$reload = true;
}
}
if($reload)
return $this->activated($id);
}
return $this->successResponse($networks); return $this->successResponse($networks);
} }