clqms-be/app/Controllers/HomeController.php
mahdahar 425595f5c0 feat: Implement custom ResponseTrait with automatic empty string to null conversion
- Create App\Traits\ResponseTrait that wraps CodeIgniter\API\ResponseTrait
- Add json_helper with convert_empty_strings_to_null() and prepare_json_response() functions
- Replace all imports of CodeIgniter\API\ResponseTrait with App\Traits\ResponseTrait across all controllers
- Add 'json' helper to BaseController helpers array
- Ensure consistent API response formatting across the application
2026-02-18 10:15:47 +07:00

34 lines
840 B
PHP

<?php
namespace App\Controllers;
use App\Traits\ResponseTrait;
use CodeIgniter\Controller;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
use Firebase\JWT\ExpiredException;
use Firebase\JWT\SignatureInvalidException;
use Firebase\JWT\BeforeValidException;
use CodeIgniter\Cookie\Cookie;
class HomeController extends Controller {
use ResponseTrait;
public function index() {
// $token = $this->request->getCookie('token');
// $key = getenv('JWT_SECRET');
// // Decode Token dengan Key yg ada di .env
// $decodedPayload = JWT::decode($token, new Key($key, 'HS256'));
// return $this->respond([
// 'status' => 'success',
// 'code' => 200,
// 'message' => 'Authenticated',
// 'data' => $decodedPayload
// ], 200);
}
}