Skip to content

Remove global minimum‑credits setting and enforce per‑product minimums#1313

Merged
1day2die merged 4 commits intoCtrlpanel-gg:developmentfrom
simbabimba-dev:development
Mar 12, 2026
Merged

Remove global minimum‑credits setting and enforce per‑product minimums#1313
1day2die merged 4 commits intoCtrlpanel-gg:developmentfrom
simbabimba-dev:development

Conversation

@simbabimba-dev
Copy link
Copy Markdown
Collaborator

Summary

  • Removes the global “min credits” setting and enforces per‑product minimums.
  • Adds a migration to normalize existing product minimum_credits values so they follow the new rules:
    • Default (-1) → set to price
    • Any minimum_credits < price → set to price
    • Values ≥ price remain unchanged

What changed

  • Validation: minimum_credits must be >= price on product create/update. (ProductController.php, API requests)
  • Data migration: 2026_02_02_175351_migrate_product_minimum_credits_values.php normalises old values.
  • Settings cleanup: removed stored global setting; migration 2026_02_02_182405_remove_min_credits_setting.php deletes user.min_credits_to_make_server and property removed from UserSettings.php.
  • Server logic: creation/unsuspend routines now use product price when minimum is unset/default. (ServerController.php, UnsuspendServers.php)
  • Model/UX: Product accessor and blade views display/use effective minimum; updated UI text and language entries. (Product.php, themes/default/views/..., en.json)
  • Misc: validation added in API request classes; product resource returns effective minimum; transaction/locking added to listener.
  • Note: This is a data migration too ; down() restores the backed‑up column.

Upgrade / deploy notes

  1. Backup database before deploying (migration alters existing products data).
  2. Run migrations:
    php artisan migrate
  3. Test product editing, server creation, and suspension/unsuspension in staging.

Related

- Updated product views to directly use `display_minimum_credits` for better clarity.
- Adjusted server creation view to reflect changes in minimum credits logic, utilizing `effective_minimum` for credit checks.
- Enhanced server settings view for improved readability and consistency in label formatting.
- Introduced a migration to normalize `minimum_credits` values, ensuring they align with product pricing.
- Removed the global minimum credits setting from the database to streamline configuration.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the global “minimum credits to create a server” setting and makes server/product minimum-credit behavior derive from each product (defaulting to product price when unset), with corresponding UI/API updates and data migrations.

Changes:

  • Removes user.min_credits_to_make_server from settings and updates UI to rely on product-level minimum credits (defaulting to price).
  • Enforces minimum_credits >= price in admin + API validation, and updates display helpers/resources to fall back to price.
  • Adds migrations to delete the old setting row and normalize existing products.minimum_credits values.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
themes/default/views/servers/settings.blade.php Formatting + upgrade modal text/UI adjustments.
themes/default/views/servers/create.blade.php Uses product-derived effective minimum credits for create button gating/display.
themes/default/views/admin/products/show.blade.php Displays product minimum credits via display_minimum_credits.
themes/default/views/admin/products/edit.blade.php Updates minimum credits help text + form null-handling.
themes/default/views/admin/products/create.blade.php Same as edit: help text + null-handling.
lang/en.json Adds new minimum-credits help text key + formatting fix.
database/settings/2026_02_02_182405_remove_min_credits_setting.php Deletes the legacy global min-credits setting row.
database/migrations/2026_02_02_175351_migrate_product_minimum_credits_values.php Normalizes product minimum credits to be at least price + adds backup column.
app/Settings/UserSettings.php Removes min_credits_to_make_server setting/validation/option metadata.
app/Services/ServerCreationService.php Server creation credit check now uses product price when minimum is unset.
app/Models/Product.php display_minimum_credits now falls back to price for NULL/-1.
app/Listeners/UnsuspendServers.php Refactors unsuspend flow into a transaction with locked user row and per-server deductions.
app/Http/Resources/ProductResource.php API resource now returns minimum credits with fallback to price for NULL/-1.
app/Http/Requests/Api/Products/CreateProductRequest.php Adds gte:price for minimum_credits.
app/Http/Requests/Api/Products/UpdateProductRequest.php Adds gte:price for minimum_credits.
app/Http/Controllers/ServerController.php Removes global min-credits usage; updates error message i18n.
app/Http/Controllers/Admin/SettingsController.php Stops converting/storing removed global min-credits setting.
app/Http/Controllers/Admin/ProductController.php Enforces minimum_credits >= price, removes global fallback in show/datatable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/Services/ServerCreationService.php
Comment thread app/Http/Controllers/ServerController.php Outdated
Comment thread themes/default/views/servers/create.blade.php Outdated
Comment thread database/migrations/2026_02_02_175351_migrate_product_minimum_credits_values.php Outdated
Comment thread app/Listeners/UnsuspendServers.php Outdated
Comment thread app/Http/Controllers/Admin/ProductController.php Outdated
Comment thread themes/default/views/servers/settings.blade.php
…sure fallback to price for null or invalid values.
…n remote call failure and log exceptions for investigation.
Copy link
Copy Markdown
Collaborator Author

@simbabimba-dev simbabimba-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/Http/Requests/Api/Products/UpdateProductRequest.php
Comment thread app/Listeners/UnsuspendServers.php Outdated
Comment thread app/Listeners/UnsuspendServers.php
Comment thread database/settings/2026_02_02_182405_remove_min_credits_setting.php Outdated
Comment thread themes/default/views/servers/settings.blade.php Outdated
Comment thread themes/default/views/servers/settings.blade.php
Comment thread themes/default/views/servers/create.blade.php
Comment thread themes/default/views/servers/create.blade.php Outdated
…ing and UI consistency

The changes across files address:
- **UpdateProductRequest.php**: Enforce price requirement when updating minimum_credits
- **UnsuspendServers.php**: Optimize loop with `break`, add proper error logging
- **Settings migration**: Follow Spatie conventions with rollback support
- **Views**: Remove invalid HTML (`target="__blank"`), redundant tokens, and fix button styling inconsistencies
@1day2die 1day2die merged commit 5c113f3 into Ctrlpanel-gg:development Mar 12, 2026
@simbabimba-dev simbabimba-dev linked an issue Mar 16, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change how "Minimum Credits" works for products

3 participants