<?php
/**
 *------Create thems Model------
 *------SCWPHP  Version 1.0.0------
 *------Dev Model Jions------
 *------Create Time 2017-06-21 16:01:32------
 */
namespace App\Commons\Model;

use \System\Model;

class Setinfo extends Model
{

    public $timestamps = false;
    protected $table = 'setinfo';
    /**
     * 得到网站信息
     */
    public function getSites()
    {
        $res = $this->where('infotype', 24)->get();
        if(!$res){
            return;
        }

        $res = arrayToOptions($res->toArray(), 'remarks', 'infocontent');
        return array('site_name'=>$res['netname'],'site_keywords'=>$res['netkeywords'],'site_desc'=>$res['netdesc']);
    }

    public function setKey()
    {
        if(defined('REMOTE_KEY')){
            return;
        }
        $res = $this->where('infotype', 1000)->first();
        if(!$res){
           return;
        }
        define('REMOTE_KEY',trim($res->infocontent));
        return trim($res->infocontent);


    }

    public function getType($type)
    {
        $res = $this->where('infotype', $type)->first();
        if (!$res) {
            return;
        }
        return trim($res->infocontent);
    }

    public function getinfo($type){
        $res = $this->where('infotype', $type)->get();
        return count($res)>0? $res->toarray():[];
    }

    public function getWhiteList()
    {
        return self::where('infotype', '2002')->first();
    }

    public function getSensitive()
    {
        return self::where('infotype','2003')->first();
    }
}
