45 lines
1.4 KiB
PHP
Executable File
45 lines
1.4 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Country;
|
|
use App\Traits\ApiResponser;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
class HelperController extends Controller
|
|
{
|
|
use ApiResponser;
|
|
/**
|
|
* Create a new controller instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function countries()
|
|
{
|
|
$countries = DB::select('SELECT id , name , code_dial , code_country FROM countries_currencies WHERE id IN (
|
|
SELECT distinct c.id FROM networks n INNER JOIN countries_currencies c ON n.country_id=c.id INNER JOIN configWallet cw ON cw.id_network = n.id WHERE status = 1
|
|
);');
|
|
return $this->successResponse($countries);
|
|
}
|
|
|
|
public function paying_networks($id_country)
|
|
{
|
|
$networks = DB::select('SELECT n.id , n.name , c.type FROM networks n INNER JOIN configWallet c ON c.id_network = n.id WHERE n.id IN ( SELECT distinct id_network FROM paying_networks )
|
|
AND status = 1 AND country_id = :id;',['id'=>$id_country]);
|
|
foreach ($networks as$network){
|
|
if($network->type == 'ilink')
|
|
$network->type = 'ilink-world';
|
|
}
|
|
return $this->successResponse($networks);
|
|
}
|
|
|
|
public function country($code_dial){
|
|
return $this->successResponse(Country::where('code_dial',$code_dial)->firstOrFail());
|
|
}
|
|
}
|