'integer', ]; /** * 获取关联的产出限制 * * @return BelongsTo */ public function outputLimit(): BelongsTo { return $this->belongsTo(ItemOutputLimit::class, 'limit_id'); } /** * 增加计数 * * @param int $count 增加的数量 * @return bool */ public function incrementCount(int $count = 1): bool { $this->current_count += $count; return $this->save(); } /** * 重置计数 * * @return bool */ public function resetCount(): bool { $this->current_count = 0; $this->last_reset_time = now(); return $this->save(); } /** * 检查是否达到限制 * * @return bool */ public function isLimitReached(): bool { $limit = $this->outputLimit; if (!$limit) { return false; } return $this->current_count >= $limit->max_quantity; } }