clqms-be/app/Controllers/Religion.php

28 lines
668 B
PHP
Raw Normal View History

<?php
namespace App\Controllers;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
2025-08-01 11:37:03 +07:00
class Religion extends Controller {
use ResponseTrait;
2025-08-01 11:37:03 +07:00
public function __construct() {
$this->db = \Config\Database::connect();
}
public function index() {
2025-08-01 11:37:03 +07:00
try {
$sql = "select * from religion";
$data = $this->db->query($sql)->getResultArray();
return $this->respond([
'status' => 'success',
2025-08-01 11:37:03 +07:00
'message'=> "Religion fetched successfully",
'data' => $data,
2025-08-01 11:37:03 +07:00
], 200);
} catch (\Exception $e) {
return $this->failServerError('Something went wrong');
}
}
}