<?php


namespace Database;

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

class Sendmsg extends Model
{
    protected $table = 'sendmsg';

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

    public static function getMsgs()
    {
        return DB::table('sendmsg')->get();
    }

    public static function addMsg($chatid, $msgid)
    {
        return DB::table('sendmsg')->insertGetId(['chatid' => $chatid, 'msgid'=> $msgid]);
    }

    public static function hasMsgs()
    {
        return DB::table('sendmsg')->exists();
    }

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

    public static function updateLastId($id, $values)
    {
        DB::table('sendmsg')->where('id', $id)->update(['last_id' => $values]);
        return true;
    }

    public static function updatePause($id, $values)
    {
        DB::table('sendmsg')->where('id', $id)->update(['pause' => $values]);
        return true;
    }

    public static function updaeCount($id, $values)
    {
        DB::table('sendmsg')->where('id', $id)->update(['count' => $values]);
        return true;
    }
}
