api code global jain

This commit is contained in:
Abhishek Mali
2025-11-05 10:37:10 +05:30
commit 52fe7e2bec
2834 changed files with 1784903 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
<?php
namespace App\Repositories\Api\Access\Country;
interface CountryInterface
{
public function getCountryCodeList();
}

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Repositories\Api\Access\Country;
use App\Models\Country;
use App\Constant\Constant;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use App\Repositories\Api\Access\Country\CountryInterface;
class CountryRepository implements CountryInterface
{
/**
* @var Country
*/
protected $country;
/**
* @param Country $country
* CountryRepository constructor.
*
*/
public function __construct(Country $country)
{
$this->country = $country;
}
/**
* @return array
*/
public function getCountryCodeList()
{
$response = [];
try {
$countryData = $this->country->select('*', DB::raw('CONCAT(phone_code, " ", name) AS label'))->get()->toArray();
if ($countryData) {
$response['countries'] = $countryData;
$response['status'] = Constant::CODE_200;
} else {
$response['countries'] = [];
$response['status'] = Constant::CODE_401;
}
} catch (\Exception $ex) {
Log::error($ex);
$response['message'] = trans('auth.something_went_wrong');
$response['status'] = Constant::CODE_403;
}
return $response;
}
}