'datetime', 'last_login_at' => 'datetime', 'type' => 'integer', 'store_id' => 'integer', 'supplier_id' => 'integer', 'status' => 'integer', ]; /** * 关联门店(type=1 时有效) */ public function store(): BelongsTo { return $this->belongsTo(StoreModel::class, 'store_id', 'id'); } /** * 关联供应商(type=2 时有效) */ public function supplier(): BelongsTo { return $this->belongsTo(SupplierModel::class, 'supplier_id', 'id'); } /** * 用户通知 */ public function notices(): HasMany { return $this->hasMany(NoticeModel::class, 'user_id', 'id'); } /** * 是否已绑定业务主体(门店或供应商) */ public function isBound(): bool { return $this->type === self::TYPE_STORE && $this->store_id > 0 || $this->type === self::TYPE_SUPPLIER && $this->supplier_id > 0; } }