<?php

namespace App\Models;

use CodeIgniter\Model;
use App\Models\_query_reader;

class _logger extends Model
{
    #Constructor to set some default values at class load
    public function __construct()
    {
        // parent::__construct();
        $this->query_reader = new _query_reader();
        $this->request = \Config\Services::request();
    }

    # Add an event
    public function add_event($eventDetails)
    {
        $this->agent = $this->request->getUserAgent();
        return $this->query_reader->run('add_event_log', array('log_code'=>$eventDetails['log_code'], 'result'=>$eventDetails['result'], 'details'=>$eventDetails['details']."|url=".uri_string()."|ipaddress=".$this->request->getIPAddress()."|browser=".$this->agent->getBrowser()."--".$this->agent->getVersion()."--".$this->agent->getPlatform()));
    }
}
