56 lines
1.2 KiB
PHP
56 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
/**
|
|
* 通知模型(小程序端消息:订单 / 价格变更 / 系统;user_id=0 为全员广播)
|
|
*/
|
|
class NoticeModel extends Model
|
|
{
|
|
/** 通知类型:订单 */
|
|
public const TYPE_ORDER = 'order';
|
|
/** 通知类型:价格变更 */
|
|
public const TYPE_PRICE = 'price';
|
|
/** 通知类型:系统 */
|
|
public const TYPE_SYSTEM = 'system';
|
|
|
|
/** 未读 */
|
|
public const UNREAD = 0;
|
|
/** 已读 */
|
|
public const READ = 1;
|
|
|
|
/** 全员广播时的 user_id 约定值 */
|
|
public const BROADCAST_USER_ID = 0;
|
|
|
|
protected $table = 'notice';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $fillable = [
|
|
'user_id',
|
|
'type',
|
|
'title',
|
|
'content',
|
|
'data',
|
|
'is_read',
|
|
'read_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'data' => 'array',
|
|
'is_read' => 'integer',
|
|
'user_id' => 'integer',
|
|
'read_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* 接收用户(user_id=0 表示全员广播,无对应用户)
|
|
*/
|
|
public function user(): BelongsTo
|
|
{
|
|
return $this->belongsTo(UserModel::class, 'user_id', 'id');
|
|
}
|
|
}
|