51 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
		
		
			
		
	
	
			51 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			PHP
		
	
	
|  | <?php | |||
|  | 
 | |||
|  | namespace app\model; | |||
|  | 
 | |||
|  | class Message extends Base | |||
|  | { | |||
|  |     // 消息类型
 | |||
|  |     public const TYPE_SYSTEM    = 'system'; // 系统消息
 | |||
|  |     public const TYPE_NOTICE    = 'notice'; // 通知消息
 | |||
|  |     public const TYPE_REMINDERS = 'reminders'; // 日程提醒
 | |||
|  | 
 | |||
|  |     // 发送范围
 | |||
|  |     public const TARGET_ALL  = 'all'; // 所有用户
 | |||
|  |     public const TARGET_PART = 'part'; // 部分用户,与target_list组合查询
 | |||
|  | 
 | |||
|  | 
 | |||
|  |     /** | |||
|  |      * 消息类型文本描述 | |||
|  |      * @return string[] | |||
|  |      */ | |||
|  |     public static function typeTextList(): array | |||
|  |     { | |||
|  |         return [ | |||
|  |             self::TYPE_SYSTEM    => '系统消息', | |||
|  |             self::TYPE_NOTICE    => '通知消息', | |||
|  |             self::TYPE_REMINDERS => '日程提醒', | |||
|  |         ]; | |||
|  |     } | |||
|  | 
 | |||
|  |     /** | |||
|  |      * 消息类型文本描述 | |||
|  |      * @return string[] | |||
|  |      */ | |||
|  |     public static function targetTextList(): array | |||
|  |     { | |||
|  |         return [ | |||
|  |             self::TARGET_ALL  => '所有用户', | |||
|  |             self::TARGET_PART => '部分用户', | |||
|  |         ]; | |||
|  |     } | |||
|  | 
 | |||
|  | 
 | |||
|  |     /** | |||
|  |      * 获取列表 | |||
|  |      */ | |||
|  |     public static function getList($per = 20) | |||
|  |     { | |||
|  |         return self::order("create_time desc") | |||
|  |             ->paginate($per); | |||
|  |     } | |||
|  | } |