Initial commit - CMS Gov Bapenda Garut dengan EditorJS

This commit is contained in:
2026-01-05 06:47:36 +07:00
commit bd649bd5f2
634 changed files with 215640 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class AuditLogModel extends Model
{
protected $table = 'audit_logs';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['user_id', 'action', 'ip_address', 'user_agent', 'created_at'];
protected bool $allowEmptyInserts = false;
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = null;
protected $deletedField = null;
public function logAction(string $action, ?int $userId = null): bool
{
$request = service('request');
$data = [
'user_id' => $userId,
'action' => $action,
'ip_address' => $request->getIPAddress(),
'user_agent' => $request->getUserAgent()->getAgentString(),
'created_at' => date('Y-m-d H:i:s'),
];
try {
return $this->insert($data);
} catch (\Exception $e) {
log_message('error', 'Audit log insert failed: ' . $e->getMessage());
return false;
}
}
}