<?php


namespace Database;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Capsule\Manager as DB;

class QuestionUsers extends Model
{
    protected $table = 'question_users';

    public static function hasQuestion($id)
    {
        return DB::table('question_users')->select('id')->where('id', $id)->exists();

    }

    public static function getQuestion($id)
    {
        return DB::table('question_users')->where('id', $id)->first();
    }

    public static function addQuestion($chatid, $question, $type, $sex)
    {
        return DB::table('question_users')->insertGetId(['chatid' => $chatid,'question'=>$question,'type'=>$type,'sex'=>$sex]);
    }

    public static function removeQuestion($id)
    {
        return DB::table('question_users')->where('id', $id)->delete();
    }
}
