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

    protected $table = 'doorprize';
    public $timestamps = true;

    public function users() {
        return $this->belongsToMany(User_model::class, 'user_doorprize', 'doorprize_id', 'user_id');
    }

    public static function get_dropdown() {
        $query = static::get_dbo()->get();
        $return = [null => lang('placeholder_select', ['{name}' => lang('doorprize')])];
        if ($query->count() >= 1) {
            $return = $return + $query->pluck('nama', 'id')->toArray();
        }
        return $return;
    }

}
