Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public static function defaultForm(Schema $schema): Schema
->label(trans('server/database.remote')),
TextInput::make('max_connections')
->label(trans('server/database.max_connections'))
->formatStateUsing(fn (Database $database) => $database->max_connections === 0 ? $database->max_connections : 'Unlimited'),
->formatStateUsing(fn (Database $database) => $database->max_connections === 0 ? trans('server/database.unlimited') : $database->max_connections),
Comment on lines 99 to +101
Copy link

@coderabbitai coderabbitai bot Dec 24, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check database migrations for max_connections definition
rg "max_connections" --type=php -g "**/database/migrations/**" -C 3

echo "---"

# Check the Database model for validation and nullability
cat -n app/Models/Database.php | head -100

echo "---"

# Search for any null assignments or nullable casts
rg -n "max_connections" app/Models/Database.php -C 2

Repository: pelican-dev/panel

Length of output: 6086


🏁 Script executed:

#!/bin/bash
# Check if max_connections is set to null anywhere
rg -n "max_connections\s*=\s*null" --type=php -C 2

echo "---"

# Check for nullable in migration or model
rg -n "nullable.*max_connections|max_connections.*nullable" --type=php -C 2

Repository: pelican-dev/panel

Length of output: 1041


null handling fix needed.

The field is indeed nullable—the migration explicitly allows it (->nullable()) and validation confirms this ('nullable', 'integer'). The current code only checks for zero values, so null entries would display as empty instead of "Unlimited". Update the formatStateUsing logic to handle both cases:

->formatStateUsing(fn (Database $database) => $database->max_connections === 0 || $database->max_connections === null ? trans('server/database.unlimited') : $database->max_connections)
🤖 Prompt for AI Agents
In app/Filament/Server/Resources/Databases/DatabaseResource.php around lines 99
to 101, the formatStateUsing callback only treats zero as "Unlimited" but the
max_connections field is nullable, so null values render empty; update the
callback to treat both null and zero as "Unlimited" (i.e., check for null OR
zero) and return trans('server/database.unlimited') in those cases, otherwise
return the numeric value.

Copy link
Member

@rmartinoscar rmartinoscar Dec 24, 2025

Choose a reason for hiding this comment

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

Suggested change
TextInput::make('max_connections')
->label(trans('server/database.max_connections'))
->formatStateUsing(fn (Database $database) => $database->max_connections === 0 ? $database->max_connections : 'Unlimited'),
->formatStateUsing(fn (Database $database) => $database->max_connections === 0 ? trans('server/database.unlimited') : $database->max_connections),
->formatStateUsing(fn (Database $database) => $database->max_connections ?: trans('server/database.unlimited')),

Copy link

Choose a reason for hiding this comment

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

@rmartinoscar Thanks for the cleaner approach! Your suggestion using truthiness ($database->max_connections ? ... : ...) correctly handles both null and 0 values, since both are falsy in PHP. This is more concise than explicitly checking for each case. 👍

TextInput::make('jdbc')
->label(trans('server/database.jdbc'))
->password()->revealable()
Expand Down
1 change: 1 addition & 0 deletions lang/en/server/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
'username' => 'Username',
'password' => 'Password',
'remote' => 'Remote',
'unlimited' => 'Unlimited',
'created_at' => 'Created at',
'name' => 'Database Name',
'name_hint' => 'Leaving this blank will auto generate a random name',
Expand Down