'投放中', 'scheduled' => '待上线', 'expired' => '已结束', 'disabled' => '已停用']; public static function status(array $row, string $now): string { if ((int)$row['status'] !== 1) return 'disabled'; if ($row['starts_at'] && $row['starts_at'] > $now) return 'scheduled'; if ($row['ends_at'] && $row['ends_at'] < $now) return 'expired'; return 'active'; } public static function filter(Builder $query, string $status, string $now): Builder { if ($status === '') return $query; if ($status === 'disabled') return $query->where('status', '<>', 1); $query->where('status', 1); if ($status === 'scheduled') return $query->where('starts_at', '>', $now); $query->where(fn ($q) => $q->whereNull('starts_at')->orWhere('starts_at', '<=', $now)); if ($status === 'expired') return $query->where('ends_at', '<', $now); return $query->where(fn ($q) => $q->whereNull('ends_at')->orWhere('ends_at', '>=', $now)); } }