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

    protected $table = 'user_doorprize';
    public $timestamps = true;
    public $primaryKey = null;
    public $incrementing = false;


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

    public function doorprize() {
        return $this->belongsTo(Doorproize_model::class, 'doorprize_id', 'id');
    }

    /**
     * Scope a query to only include popular users.
     *
     * @param  \Illuminate\Database\Eloquent\Builder  $query
     * @return \Illuminate\Database\Eloquent\Builder
     */
    public function scopeWhere_key($query, $doorprize_id = null, $user_id = null) {
        return $query->where('doorprize_id', $doorprize_id)->where('user_id', $user_id);
    }

}
