28 lines
741 B
PHP
28 lines
741 B
PHP
<?php
|
|
namespace App\Controllers;
|
|
|
|
use CodeIgniter\API\ResponseTrait;
|
|
use CodeIgniter\Controller;
|
|
|
|
class Country extends Controller {
|
|
use ResponseTrait;
|
|
|
|
public function __construct() {
|
|
$this->db = \Config\Database::connect();
|
|
}
|
|
|
|
public function index() {
|
|
try {
|
|
$sql = "select * from country";
|
|
$data = $this->db->query($sql)->getResultArray();
|
|
|
|
return $this->respond([
|
|
'status' => 'success',
|
|
'message'=> "Country fetched successfully",
|
|
'data' => $data,
|
|
], 200);
|
|
} catch (\Exception $e) {
|
|
return $this->failServerError('Something went wrong');
|
|
}
|
|
}
|
|
} |