<?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 Visitor_absen_model
 *
 * @author Andhy Taslin <andhy@earworks.co.id>
 * @since 1.0
 */
class Visitor_absen_model extends MY_Model {

    protected $table = "visitor_absen";
    public $timestamps = true;
    public $incrementing = false;
    public $primaryKey = ['absen_id', 'user_id', 'visitor_id'];

    public function scopeWhere_key($query, $absen_id = null, $user_id = null, $visitor_id = null) {
        return $query
                ->where('absen_id', $absen_id)
                ->where('user_id', $user_id)
                ->where('visitor_id', $visitor_id);
    }

    public function absen() {
        return $this->belongsTo(Absen_model::class, 'absen_id');
    }

    public function user() {
        return $this->belongsTo(User_model::class, 'user_id');
    }

    public function visitor() {
        return $this->belongsTo(User_model::class, 'visitor_id');
    }

}
