<?php

/*
 * *************************************************
 * Copyright (C) 2021 Earworks.                    *
 * Codeigniter Project Template Modification       *
 * Please contact our email for more information : *
 * contact@earworks.co.id                          *
 * *************************************************
 */

defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Description of Absen_model
 *
 * @author Andhy Taslin <andhy@earworks.co.id>
 * @since 1.0
 */
class Absen_model extends MY_Model {

    public $table = 'absen';
    public $timestamp = true;

    const TIPE_ACARA = 1; // define later

    public static function tipe_label($selected = null) {
        $lib = [
            self::TIPE_ACARA => lang('ACARA')
        ];
        return array_key_exists($selected, $lib) ? $lib[$selected] : $lib;
    }
    
    public function users() {
        return $this->belongsToMany(User_model::class, 'user_absen', 'absen_id', 'user_id');
    }
    public function visitors() {
        return $this->belongsToMany(User_model::class, 'visitor_absen', 'absen_id', 'visitor_id');
    }
}
