+ Fix bug

This commit is contained in:
DJERY-TOM 2020-05-05 23:29:26 +01:00
parent 59e291b7b8
commit c376748298
1 changed files with 19 additions and 3 deletions

View File

@ -24,7 +24,7 @@ class WalletController extends Controller
public function activated($id_agent) public function activated($id_agent)
{ {
$networks = DB::select('SELECT ne.name as network , countries.name AS country, w.id, na.id AS id_networkAgent , cg.category FROM agents ag $networks = DB::select('SELECT ne.name as network , countries.name AS country, w.id, w.balance_princ , w.balance_com, w.created_date, 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 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 ( 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]);
@ -46,11 +46,27 @@ class WalletController extends Controller
return $this->activated($id); return $this->activated($id);
} }
// Return only single wallet if it is hypervisor or supervisor // Return only single wallet if it is hypervisor or supervisor
if(in_array( $category , ['hyper','super'])) if(in_array( $category , ['hyper','super'])){
// Remove unnecessary fields
$networks = $this->array_except($networks,['id_networkAgent','category']);
return $this->successResponse(collect($networks)->first()); return $this->successResponse(collect($networks)->first());
else }else{
// Remove unnecessary fields
$networks = $this->array_except($networks,['id_networkAgent','category','balance_princ','balance_com','created_date','taux_com_client_depot']);
return $this->successResponse($networks); return $this->successResponse($networks);
}
}
private function array_except($array, $keys){
foreach ($array as $row){
foreach($keys as $key){
unset($row->$key);
}
}
return $array;
} }
public function show($id_wallet) public function show($id_wallet)