56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?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;
|
|
}
|
|
}
|
|
|