+ Change response format
This commit is contained in:
parent
95bfc8f3bd
commit
35befe4b1c
|
@ -29,13 +29,13 @@ class WalletController extends Controller
|
||||||
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 countries ON ne.country_id=countries.id LEFT JOIN wallets ON na.id = wallets.id_networkAgent WHERE ag.id= :id AND network_id IN (
|
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 countries ON ne.country_id=countries.id LEFT JOIN wallets ON na.id = wallets.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]);
|
||||||
|
|
||||||
return $this->successResponse($networks);
|
return $this->successResponse($this->formatResponse(Response::HTTP_OK,$networks,null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show($id_wallet)
|
public function show($id_wallet)
|
||||||
{
|
{
|
||||||
$wallet = Wallet::findOrFail($id_wallet);
|
$wallet = Wallet::findOrFail($id_wallet);
|
||||||
return $this->successResponse($wallet);
|
return $this->successResponse($this->formatResponse(Response::HTTP_OK,$wallet,null));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,16 @@ trait ApiResponser
|
||||||
|
|
||||||
public function errorResponse($message , $code)
|
public function errorResponse($message , $code)
|
||||||
{
|
{
|
||||||
return response()->json(['error' => $message , 'code'=> $code], $code);
|
return response()->json($this->formatResponse($code,null,$message), $code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function errorMessage($message , $code)
|
public function errorMessage($message , $code)
|
||||||
{
|
{
|
||||||
return response($message ,$code)->header('Content-Type', 'application/json');
|
return response($message ,$code)->header('Content-Type', 'application/json');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function formatResponse(int $status, $response = null , $error = null)
|
||||||
|
{
|
||||||
|
return ['status' => $status , 'response' => $response , 'error' => $error];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue