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;
|
|
|
|
/**
|
|
* 通知模型(小程序端消息:订单 / 价格变更 / 系统;store_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;
|
|
|
|
/** 全员广播时的 store_id 约定值 */
|
|
public const BROADCAST_STORE_ID = 0;
|
|
|
|
protected $table = 'notice';
|
|
protected $primaryKey = 'id';
|
|
|
|
protected $fillable = [
|
|
'store_id',
|
|
'type',
|
|
'title',
|
|
'content',
|
|
'data',
|
|
'is_read',
|
|
'read_at',
|
|
];
|
|
|
|
protected $casts = [
|
|
'data' => 'array',
|
|
'is_read' => 'integer',
|
|
'store_id' => 'integer',
|
|
'read_at' => 'datetime',
|
|
];
|
|
|
|
/**
|
|
* 接收门店(store_id=0 表示全员广播,无对应门店)
|
|
*/
|
|
public function store(): BelongsTo
|
|
{
|
|
return $this->belongsTo(StoreModel::class, 'store_id', 'id');
|
|
}
|
|
}
|