add
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?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(?string $category = null): array
|
||||
{
|
||||
$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(): array
|
||||
{
|
||||
return self::where('status', 1)
|
||||
->whereNotNull('category')
|
||||
->where('category', '<>', '')
|
||||
->group('category')
|
||||
->column('category');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user