<?php

namespace App\Models;

use CodeIgniter\Model;

class ActivityLogModel extends Model
{
    protected $table            = 'activity_logs';
    protected $primaryKey       = 'id_log';
    protected $allowedFields    = ['id_user', 'aktivitas', 'timestamp']; // Pastikan ini sesuai kolom

    protected $useTimestamps = true; 
    protected $createdField  = 'timestamp'; // UBAH INI ke timestamp
    protected $updatedField  = '';

    public function logActivity($userId, $message)
    {
        return $this->insert([
            'id_user'   => $userId,
            'aktivitas' => $message,
        ]);
    }
}