+ Update get actives wallet method
This commit is contained in:
parent
7cbf402758
commit
59e291b7b8
|
@ -24,16 +24,19 @@ class WalletController extends Controller
|
|||
|
||||
public function activated($id_agent)
|
||||
{
|
||||
$networks = DB::select('SELECT ne.name as network , countries.name AS country, w.id, na.id AS id_networkAgent FROM agents ag
|
||||
$networks = DB::select('SELECT ne.name as network , countries.name AS country, w.id, 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 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]);
|
||||
|
||||
// Create wallet if is not exist
|
||||
$category = null;
|
||||
if($networks){
|
||||
$reload = false;
|
||||
$id = $id_agent;
|
||||
foreach ($networks as $network){
|
||||
$category = $network->category;
|
||||
// Create wallet if is not exist
|
||||
if(!$network->id){
|
||||
DB::insert('INSERT INTO wallets (id_networkAgent) VALUES (?);', [$network->id_networkAgent]);
|
||||
$reload = true;
|
||||
|
@ -42,7 +45,12 @@ class WalletController extends Controller
|
|||
if($reload)
|
||||
return $this->activated($id);
|
||||
}
|
||||
return $this->successResponse($networks);
|
||||
|
||||
// Return only single wallet if it is hypervisor or supervisor
|
||||
if(in_array( $category , ['hyper','super']))
|
||||
return $this->successResponse(collect($networks)->first());
|
||||
else
|
||||
return $this->successResponse($networks);
|
||||
}
|
||||
|
||||
public function show($id_wallet)
|
||||
|
|
Loading…
Reference in New Issue