<?php
/**
 * Created by PhpStorm.
 * User: sicilon_IT
 * Date: 2021/5/16
 * Time: 12:05
 */
namespace app\index\model;
use think\Model;
class noticemodel extends Model{
    protected $table='t_notice';

    /*
     * 20210516
     */
    public function insinfo($arr){
        $this->allowField(true)->isUpdate(false)->setAttr('id',null)->save($arr);
        return $this->id;
    }

    /*
     * 20210517
     * 获取所有的有效公告接口
     */
    public function selalllist(){
        $where_arr['isactive']=1;
        $rlist=$this->where($where_arr)->order('id','desc')->select();
        $rlist=collection($rlist)->toArray();
        return $rlist;
    }

    /*
 * 20210517
 */
    public function selnewmsg(){

        $where_arr['isactive']=1;
        $rlist=$this->where($where_arr)->order('id','desc')->limit(0,1)->select();
        $rlist=collection($rlist)->toArray();
        return $rlist;
    }

    /*
     * 20230215
     */
    public function sellistbycid($cid){
        $where_arr['companyid']=$cid;
        $where_arr['isactive']=1;
        $rlist=$this->where($where_arr)->order('id','desc')->select();
        $rlist=collection($rlist)->toArray();
        return $rlist;
    }

    /*
     * 20230218
     */
    public function selnewmsgbycid($cid){
        $where_arr['isactive']=1;
        $where_arr['companyid']=$cid;
        $rlist=$this->where($where_arr)->order('id','desc')->limit(0,1)->select();
        $rlist=collection($rlist)->toArray();
        return $rlist;
    }

}