56 lines
1.1 KiB
PHP
56 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 文件功能:聊天消息模型
|
|
*
|
|
* 对应原 ASP 文件:内存 Application("_says") 变量 (用数据库做持久化归档)
|
|
*
|
|
* @author ChatRoom Laravel
|
|
*
|
|
* @version 1.0.0
|
|
*/
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* 聊天消息模型
|
|
* 负责承载聊天室文本消息、图片消息与过期图片占位消息。
|
|
*/
|
|
class Message extends Model
|
|
{
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
*
|
|
* @var array<int, string>
|
|
*/
|
|
protected $fillable = [
|
|
'room_id',
|
|
'from_user',
|
|
'to_user',
|
|
'content',
|
|
'is_secret',
|
|
'font_color',
|
|
'action',
|
|
'message_type',
|
|
'image_path',
|
|
'image_thumb_path',
|
|
'image_original_name',
|
|
'sent_at',
|
|
];
|
|
|
|
/**
|
|
* 返回模型字段的类型转换配置。
|
|
*
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'sent_at' => 'datetime',
|
|
'is_secret' => 'boolean',
|
|
];
|
|
}
|
|
}
|