| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?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 关联的用户
- */
- /**
- * App\Module\Ulogic\Models\AppMessageRecipient
- *
- * field start
- * @property int $id
- * @property int $message_id 消息ID
- * @property int $user_id 用户ID
- * @property bool $is_read 是否已读:0未读 1已读
- * @property \Carbon\Carbon $read_at 阅读时间
- * @property int $status 状态:0删除 1正常
- * @property \Carbon\Carbon $created_at 创建时间
- * @property \Carbon\Carbon $updated_at 更新时间
- * field end
- */
- class AppMessageRecipient extends Model
- {
- /**
- * 数据表名称
- *
- * @var string
- */
- protected $table = 'app_message_recipients';
- // attrlist start
- protected $fillable = [
- 'id',
- 'message_id',
- 'user_id',
- 'is_read',
- 'read_at',
- 'status',
- ];
- // attrlist end
-
- /**
- * 属性类型转换
- *
- * @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);
- }
- }
|