33 lines
839 B
PHP
Executable File
33 lines
839 B
PHP
Executable File
<?php
|
|
|
|
namespace Modules\Admin\app\Http\Controllers;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\HCountry;
|
|
use Illuminate\Http\RedirectResponse;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
use JsonException;
|
|
|
|
class CountryController extends Controller
|
|
{
|
|
public function __construct()
|
|
{
|
|
if (!class_exists(HCountry::class)) {
|
|
throw new JsonException('Helper table h_country not exist, please check model and table db.');
|
|
}
|
|
}
|
|
|
|
public function all()
|
|
{
|
|
return response()->json([
|
|
'data' => HCountry::getByCache()
|
|
->map(function($country) {
|
|
$country->flag = asset(HCountry::PUBLIC_PATH . "/$country->code.svg");
|
|
return $country;
|
|
}),
|
|
'status' => true
|
|
]);
|
|
}
|
|
}
|