Socket/app/models/chat/ChatQuickReply.php

45 lines
965 B
PHP

<?php
namespace app\models\chat;
use think\Model;
/**
* 快捷回复模型
* Class ChatQuickReply
* @package app\models\chat
*/
class ChatQuickReply extends Model
{
protected $table = 'cg_chat_quick_reply';
protected $pk = 'id';
protected $autoWriteTimestamp = true;
/**
* 获取启用的快捷回复列表
*/
public static function getEnabledList($category = null)
{
$query = self::where('status', 1);
if ($category !== null) {
$query->where('category', $category);
}
return $query->order('sort', 'asc')
->order('id', 'asc')
->select()
->toArray();
}
/**
* 获取分类列表
*/
public static function getCategories()
{
return self::where('status', 1)
->whereNotNull('category')
->where('category', '<>', '')
->group('category')
->column('category');
}
}