<?php
    /**
     * Created by PhpStorm.
     * User: Lenovo
     * Date: 2018/10/30
     * Time: 15:09
     */

    namespace App\Models;


    class ChatRooms extends  BaseModel
    {
        protected $table = 'chat_rooms';



        function getlist($where,$limit ){
            return  $this->where($where)
                ->limit($limit)
                ->get()
                ->toArray();
        }

        function addRecord($data){
            $res=$this->insert($data);
            if(!$res){
                return -6030001222;
            }
        }

        function getIdData($id){
            return $this->where("id",$id)->first();
        }

        public function updateIdData(int  $id,$data){
            return $this->where("id",$id)->update($data);
        }

        //获取所有房间 2019-01-19 anton liu
        function getAll()
        {
            $data = $this->select('id','room_name')->orderBy('id','asc')->get()->toArray();
            if(!$data){
                return -5040000522;//没有数据
            }
            return $data;
        }
    }
