| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- namespace App\Module\Ulogic\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- /**
- * 应用消息接收者模型
- *
- * @property int $id 接收记录ID
- * @property int $message_id 消息ID
- * @property int $user_id 用户ID
- * @property bool $is_read 是否已读
- * @property \Carbon\Carbon|null $read_at 阅读时间
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- *
- * @property-read AppMessage $message 关联的消息
- * @property-read \App\Models\User $user 关联的用户
- */
- class AppMessageRecipient extends Model
- {
- /**
- * 数据表名称
- *
- * @var string
- */
- protected $table = 'app_message_recipients';
- /**
- * 可批量赋值的属性
- *
- * @var array
- */
- protected $fillable = [
- 'message_id', // 消息ID
- 'user_id', // 用户ID
- 'is_read', // 是否已读
- 'read_at' // 阅读时间
- ];
- /**
- * 属性类型转换
- *
- * @var array
- */
- protected $casts = [
- 'is_read' => 'boolean',
- 'read_at' => 'datetime'
- ];
- /**
- * 获取关联的消息
- *
- * 定义与消息模型的多对一关系
- *
- * @return BelongsTo
- */
- public function message(): BelongsTo
- {
- return $this->belongsTo(AppMessage::class, 'message_id');
- }
- /**
- * 获取关联的用户
- *
- * 定义与用户模型的多对一关系
- *
- * @return BelongsTo
- */
- public function user(): BelongsTo
- {
- return $this->belongsTo(User::class);
- }
- }
|