<?php

use app\libraries\Userstamp;

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/* Author: Jorge Torres
 * Description: Login model class
 */

class Event_setting_model extends MY_Model
{
    const SETTING_ID = 1;

    public $short = "et";
    public $table;
    public $tbl;
    public $database;
    public $table_prefix = '';

    public function __construct()
    {
        parent::__construct();
        $this->database = $this->getTenantNo();
        $this->tbl = 'event_setting';
        $this->table = $this->tbl . ' ' . $this->short;

        $this->db = $this->load->database($this->database, true);
    }

    public function get_path()
    {
        return 'uploads/tenants/' . $this->getTenantNo() . '/event';
    }

    public function detail()
    {
        $res = $this->getOneRow($this->database, $this->tbl, [], ['id' => 1]);
        log_message('debug', json_encode($res));
        return $res;
    }

    public function save($params)
    {
        // if ($mode === 'c') {
        //     $this->db->insert('referral_scheme', Userstamp::create($params));
        // } else {

        // }
        $id = self::SETTING_ID;
        $this->saveDB($this->database, $this->tbl, $params, $id, 'id', [
            'updated_at' => date('Y-mm-d H:i:s'),
            'updated_by' => $this->session->userdata('userid') ?? 0,
        ]);

        return $id;
    }
}
