walletservice/app/Http/Controllers/WalletController.php

55 lines
1.8 KiB
PHP
Raw Normal View History

2020-04-15 23:08:09 +00:00
<?php
namespace App\Http\Controllers;
use App\Models\Wallet;
2020-04-15 23:08:09 +00:00
use App\Traits\ApiResponser;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
2020-04-15 23:08:09 +00:00
use Illuminate\Support\Facades\DB;
class WalletController extends Controller
{
use ApiResponser;
2020-04-15 23:08:09 +00:00
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
//
}
public function activated($id_agent)
{
2020-04-21 14:07:57 +00:00
$networks = DB::select('SELECT na.network_id ,ne.name as network , countries.name AS country,ne.country_id , w.id, w.balance_princ , w.balance_com, w.created_date, na.id AS id_networkAgent ,cw.taux_com_client_retrait, cw.taux_com_client_depot , cw.frais_min_banque_depot 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]);
2020-04-15 23:08:09 +00:00
2020-04-21 14:07:57 +00:00
return $this->successResponse($networks);
2020-04-15 23:08:09 +00:00
}
public function show($id_wallet)
{
$wallet = Wallet::findOrFail($id_wallet);
2020-04-21 14:07:57 +00:00
return $this->successResponse($$wallet);
}
2020-04-21 14:07:57 +00:00
public function create(Request $request)
{
$rules = [
'id_networkAgent'=>'required|integer|min:1'
];
$this->validate($request,$rules);
DB::insert('INSERT INTO wallets (id_networkAgent) VALUES (?);', [$request->id_networkAgent]);
return $this->successResponse('Nouveau wallet ajoute');
}
2020-04-15 23:08:09 +00:00
}