api code global jain
This commit is contained in:
8
app/Repositories/Api/Access/Country/CountryInterface.php
Normal file
8
app/Repositories/Api/Access/Country/CountryInterface.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Api\Access\Country;
|
||||
|
||||
interface CountryInterface
|
||||
{
|
||||
public function getCountryCodeList();
|
||||
}
|
||||
55
app/Repositories/Api/Access/Country/CountryRepository.php
Normal file
55
app/Repositories/Api/Access/Country/CountryRepository.php
Normal 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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user